I am trying to access my hosted JIRA via python but I get a 401 error when I try to login.
My code:
from jira import JIRAoptions = {'server': 'https://[instance_name].atlassian.net'}jira = JIRA(options, basic_auth=(username, password))
Based on https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-work-with-jira-python-api-using-google-account/qaq-p/505609 the issue is connected to my login being managed by my google account and I should have access to an alternate password but I can't find it. The help page linked there does not exist anymore, so I am guessing that the instructions are out of date. Are there any more up to date instructions available?
I'm afraid the link you reference here is 5 years old and yes, it's out of date.
I'd recommend checking out Basic auth for REST APIs It explains that for Jira Cloud today, if you want to use basic authentication, you're going to have to create and use an API token
Supplying basic auth headers If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps: Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens. Build a string of the form useremail:api_token. BASE64 encode the string. Supply an Authorization header with content Basic followed by the encoded string. For example, the string fred:fred encodes to ZnJlZDpmcmVk in base64, so you would make the request as follows:
If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:
useremail:api_token
Authorization
Basic
fred:fred
ZnJlZDpmcmVk
I hope this helps.
Andy
That did help, but it was actually a few steps ahead of the correct answer!
For future googlers, the correct way is to use the API token as your password. So in the case of a username of fred@gmail.com and an API token of t0k3n you'd use the following:
from jira import JIRAoptions = {'server': 'https://[instance_name].atlassian.net'}jira = JIRA(options, basic_auth=('fred@gmail.com', 't0k3n '))
That works for Jira, but I cannot do the same for Confluence. Any idea?
It looks like you're new here. Sign in or register to get started.