Basic Authentication Failure - Reason : AUTHENTICATED_FAILED

Prashant May 4, 2022

from jira import JIRA


JiraUserId = 'myemail@mycompany.com'
JiraApiKey = 'XMDNBQ456CFGHTY'
JiraEmailId = 'myemail@mycompany.com'
JiraServer = 'https://jira.mycompany.com'
JiraIssueKey = 'ZDFGH-4567"'

options = {'server': JiraServer}
jira = JIRA(options, basic_auth=(JiraUserId, JiraApiKey))
issue = jira.issue(JiraIssueKey)
summary = issue.fields.summary
print('ticket: ', JiraIssueKey, summary)

 

Error:
Unauthorized (401)

However, I am able to login manually to Jira. What is wrong with my code? Can someone please guide me?

1 answer

0 votes
Nikolai Nekrasov June 7, 2022

Looks like a problem with your authorization header. Had the same error thrown at me today by testing REST endpoint with curl. I tried using a PAT instead and the error went away. Then I tried changing how I pass login and pass to curl and it worked. I noticed that for some reason base64 in the header curl generated was different from the one I provided it earlier. (edit: just found out that I accidentally added a newline to my credentials before converting them to base64) So maybe your python module does something with authorization in a way that Jira doesn't like.

Another possibility is that your Jira server has basic auth for REST disabled although that's kind of a long shot.

Suggest an answer

Log in or Sign up to answer