You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python脚本连接Polarion API认证失败,请求排查帮助

Polarion Python API 认证失败排查方案

问题重现

我正在编写Python脚本将测试用例作为工作项导入Polarion,确认输入的URL、用户名和密码完全正确,但连接时触发认证失败错误。

脚本代码:

from polarion import polarion
import getpass

user = input("Username: ")
password = getpass.getpass(prompt="Password:")
server = ('http://example.com/polarion')

pol = polarion.Polarion(server, user, password, verify_certificate = ('path_to_my_certificate.crt'))

project = pol.getProject('PSA_Sandbox')
workitem = project.createWorkitem('probe_work_item')
workitem.setDescription('Das ist ein Testupload')

控制台错误:

Fault: Authentication failed.; nested exception is:
com.polarion.platform.security.AuthenticationFailedException: Sorry, but the Username or Password is invalid.

Exception: Could not log in to Polarion for user PS8

排查与解决方向

  • 修正证书参数格式:当前verify_certificate = ('path_to_my_certificate.crt')是元组类型,而API要求传入字符串路径,改为verify_certificate='path_to_my_certificate.crt'。若不确定证书有效性,可临时设置verify_certificate=False(仅测试用,生产环境禁用)排除证书干扰。
  • 检查服务器URL完整性:部分Polarion实例要求API URL指向WebService端点,需确认是否需要补充/ws路径,比如改为http://example.com/polarion/ws。
  • 核实账号权限:登录Polarion后台检查该账号是否允许API访问、是否被锁定,或是否启用了MFA(二次验证)。若开启MFA,普通账号密码认证会失效,需改用API令牌。
  • 排除密码输入异常:临时将密码硬编码到脚本中(如password='your_real_password'),测试是否能成功连接,排除getpass在终端环境下的输入问题。

内容的提问来源于stack exchange,提问作者Paul Schieder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 07:25:03