Forums

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

Jira REST API authentication - examples not working

Craig Anderson
Contributor
January 31, 2023

I'm trying to authenticate with the JIRA REST API in Python.   Using Jira Cloud.

I generated a Jira API token.

Using the jira Python package, I tried:

 

jira = JIRA(JIRA_URL, auth=(username, token))
issue = jira.issue("CM-877")

 

and got "Login failed".  I verified that 'username' and 'token' have the proper values.

 

I then tried something from the command line:

curl -D- -X GET -u mylogin@mydomain.com:TOKEN_VALUE -H "Content-Type: application/json" https://mydomain.atlassian.net/rest/api/issue/[issue name]

 

and I got "Basic authentication with passwords is deprecated".

 

I'm trying to follow the example at: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/ 

 

Does someone have code that works?

 

2 answers

1 vote
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2023

Hi @Craig Anderson

Can you try generating the base64 encode of your credentials and try this?

curl -D- -X GET -H "Authorization: Basic <your base64 code>" -H "Content-Type: application/json" "https://mydomain.atlassian.net/rest/api/2/issue/[issue name]"

Replace '<your base64 code>' with the base64 string.

You can generate the base64 string online like at https://base64.guru/converter or https://www.base64encode.net/

You have to provide your credentials like 'mylogin@mydomain.com:password'.

Hope this helps.

Thanks,
Vamsi

0 votes
Blue Ridge Consultants
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2023

You stated you're developing for Jira Cloud, but linked the API documentation for Jira Server's REST API.

 

https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/


https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/

 

Then do as Vamsi suggested and include Base64 encoding.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events