Login with python jira not working with api

Borja P July 18, 2019

Hello! I would like to know how to login to jira with the python api. My company has to jiras, one I can connect with the basis auth (jira server) and the other one is a cloud solution (I can not connect). To the jira cloud with the browser, I use my user and password. After it ask me for a second password that I have in my smartphone and changes every 30 seconds.

 

I would like to know how to reproduce this login with python. I have looked at the documentation and I think it is something like this:

 

# all values are samples and won't work in your code!
key_cert_data = None
with open(key_cert, 'r') as key_cert_file:
    key_cert_data = key_cert_file.read()

oauth_dict = {
    'access_token': 'foo',
    'access_token_secret': 'bar',
    'consumer_key': 'jira-oauth-consumer',
    'key_cert': key_cert_data
}
auth_jira = JIRA(oauth=oauth_dict)

 

However I do not know what are the parameters:

 'access_token': is that my username that I use in the browser?

'access_token_secret': is that my password?

'consumer_key': is this the second password in my smartphone?

'key_cert': what it is? 

Thank you for your help

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 19, 2019

Hi @Borja P ,

Basic authentication with username and password and cookie authentication have been removed in Cloud, as announced long time ago: Deprecation notice - Basic authentication with passwords and cookie-based authentication

 

The current ways to authenticate REST API calls against Jira Cloud are the below ones:

In above links you have detailed explanation and examples on how to use them. 

 

Also, in the below thread you find a python code snippet that shows how to authenticate a REST API call using basic authentication with API Token:

 

Finally, you may also want to have a look at the below documentation request that provides some more details and examples:

 

Let me know if this helps or if you have further questions on this topic.

 

Cheers,
Dario

Borja P July 23, 2019

Hi Dario,

Thank you for your replay. I thing is that I do not now how to get the token. The jira link is custom so I do not know how to create an API token.

The jira version is v7.9.2. When I go to my profile, it see the following message: "No applications are using your account to access JIRA data" and the is not button or link to create one.

Any suggestion?

Thank you very much for your help

BR,

Borja

Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2019

Hi @Borja P ,

As written in the documentation API Tokens only work with Cloud applications:

API tokens can be used with the Jira Cloud and Confluence Cloud REST APIs.

 

In the  original question it was mentioned that you were able to connect to Jira Server but not with Jira Cloud, and therefore all the documentation links provided so far are for Jira Cloud only. 

The links for Jira Server are the below ones:

 

Kindly review the above links (and the code sample) and, if you still have issues, provide as many details as possible about what you are trying to achieve.

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer