Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I login on jira python using google account?

Roy Healy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2019

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 JIRA
options = {'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?

1 answer

1 accepted

2 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 1, 2019

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:

  1. Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens.
  2. Build a string of the form useremail:api_token.
  3. BASE64 encode the string.
  4. 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:

I hope this helps.

Andy

Roy Healy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 5, 2019

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 JIRA
options = {'server': 'https://[instance_name].atlassian.net'}
jira = JIRA(options, basic_auth=('fred@gmail.com', 't0k3n '))

 

Like # people like this
sfavaro
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2019

That works for Jira, but I cannot do the same for Confluence. Any idea?

Suggest an answer

Log in or Sign up to answer