带有Python的Jira API在有效凭据上返回错误401 [英] Jira API with python returns error 401 on valid credentials
问题描述
我正在尝试使用Jira python库做一些非常基本的事情. 甚至在做任何事情之前,构造函数都会失败.
I am trying to use the Jira python library to do some quite basic things. Even before doing anything, the constructor fails.
address = 'https://myaddress.atlassian.net'
options = {'server': address}
un = 'my@user.com'
#un = 'my' #also doesn't work
pw = 'the_pasSword!'
cookie = (un, pw)
j = JIRA(options, basic_auth=cookie)
这是所有代码.
最后一行失败
警告:root:从GET获得可恢复的错误 https://myaddress.atlassian.net/rest/api/2/serverInfo,将重试[1/3] 在13.906688704524315s中.错误:401
WARNING:root:Got recoverable error from GET https://myaddress.atlassian.net/rest/api/2/serverInfo, will retry [1/3] in 13.906688704524315s. Err: 401
警告:root:有可恢复的错误 来自GET https://myaddress.atlassian.net/rest/api/2/serverInfo ,将 在4.071181495745648s中重试[2/3].错误:401
WARNING:root:Got recoverable error from GET https://myaddress.atlassian.net/rest/api/2/serverInfo, will retry [2/3] in 4.071181495745648s. Err: 401
警告:root:Got GET中的可恢复错误 https://myaddress.atlassian.net/rest/api/2/serverInfo,将重试[3/3] 在6.266303262421157s中.错误:401
WARNING:root:Got recoverable error from GET https://myaddress.atlassian.net/rest/api/2/serverInfo, will retry [3/3] in 6.266303262421157s. Err: 401
在Atlassian上手动尝试使用凭据可以正常工作,并且我能够登录.
Trying the credentials manually on atlassian do work, and I am able to log in.
有人知道为什么这种非常简单的连接尝试不起作用吗?
Any idea why this very straightforward attempt to connect wouldn't work?
推荐答案
他们一直在讨论基本身份验证中弃用的密码.尝试生成一个API令牌,并用它来代替您的密码.
They have been discussing deprecating passwords in basic auth. Try generating an API token and using that in replacement of your password.
address = 'https://myaddress.atlassian.net'
options = {'server': address}
un = 'my@user.com'
#un = 'my' #also doesn't work
token = 'the_tokEn'
cookie = (un, token)
j = JIRA(options, basic_auth=cookie)
这篇关于带有Python的Jira API在有效凭据上返回错误401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!