Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有python的Jira API在有效凭据上返回错误401_Python_Rest_Jira_Jira Rest Api - Fatal编程技术网

带有python的Jira API在有效凭据上返回错误401

带有python的Jira API在有效凭据上返回错误401,python,rest,jira,jira-rest-api,Python,Rest,Jira,Jira Rest Api,我正在尝试使用Jira python库来做一些非常基本的事情。 即使在做任何事情之前,构造函数也会失败 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

我正在尝试使用Jira python库来做一些非常基本的事情。 即使在做任何事情之前,构造函数也会失败

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获取可恢复错误 ,将重试[1/3] 在13.906688704524315s。错误:401

警告:root:出现可恢复错误 从现在开始,威尔 在4.071181495745648s中重试[2/3]。错误:401

警告:root:get 可从GET恢复的错误 ,将重试[3/3] 在6.266303262421157s中。错误:401

在atlassian上手动尝试凭据确实有效,并且我能够登录


知道为什么这种非常简单的连接尝试不起作用吗?

他们一直在讨论在basic auth中弃用密码。尝试生成一个API令牌,并使用它替换您的密码

请尝试以下代码:

from jira.client import JIRA
import logging
import getpass
import datetime
import os

# Clearing the screen
os.system('cls||clear')
# Getting user authentication data
print 'Please enter your authentication data'
USER = raw_input('Username: ')
PASSWORD = getpass.getpass('Password: ')
print
JIRA_URL = "YOUR_JIRA_URL"
i = datetime.datetime.now()
TODAY = ("%s/%s/%s" % (i.day, i.month, i.year) )

def connect_jira(log, jira_server, jira_user, jira_password):
    '''
    Connects to JIRA

    Returns None on error
    '''
    try:
        log.info("Connecting to JIRA: %s" % jira_server)
        jira_options = {'server': jira_server}
        jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password))
                                        # ^--- Note the tuple
        return jira
    except Exception,e:
        log.error("Failed to connect to JIRA: %s" % e)
        return e

# Creating logger
log = logging.getLogger(__name__)
# Creating a Jira connection object, jc
jc = connect_jira(log, JIRA_URL, USER, PASSWORD)

这就是你正在使用的图书馆吗?似乎有几种方法可以向JIRA进行身份验证,这取决于JIRA服务器的设置方式。错误401。这有什么不同?日志输出一个页面的html代码,该页面至少显示“error 401”less@Gulzar这在我的安装上100%有效,但是,正如你在另一个答案中正确地发现的,在新的Jira版本中,只接受令牌。这是有效的!然而。。。根据用户名,将不支持很快开始使用。我还应该做什么?看起来您应该继续使用链接到的accountID进行测试。当你使用它的时候,它会起作用吗?文档对于什么会被弃用是非常不清楚的。联系了官方支持,他们说mail+token将继续工作,就这样,谢谢!从2020年1月3日起,它不再适用于JIRA客户端2.0.0版,但仍然适用于curl call:curl-v——用户电子邮件:token
from jira.client import JIRA
import logging
import getpass
import datetime
import os

# Clearing the screen
os.system('cls||clear')
# Getting user authentication data
print 'Please enter your authentication data'
USER = raw_input('Username: ')
PASSWORD = getpass.getpass('Password: ')
print
JIRA_URL = "YOUR_JIRA_URL"
i = datetime.datetime.now()
TODAY = ("%s/%s/%s" % (i.day, i.month, i.year) )

def connect_jira(log, jira_server, jira_user, jira_password):
    '''
    Connects to JIRA

    Returns None on error
    '''
    try:
        log.info("Connecting to JIRA: %s" % jira_server)
        jira_options = {'server': jira_server}
        jira = JIRA(options=jira_options, basic_auth=(jira_user, jira_password))
                                        # ^--- Note the tuple
        return jira
    except Exception,e:
        log.error("Failed to connect to JIRA: %s" % e)
        return e

# Creating logger
log = logging.getLogger(__name__)
# Creating a Jira connection object, jc
jc = connect_jira(log, JIRA_URL, USER, PASSWORD)