Vyshnavi
Vyshnavi

Reputation: 149

Python jira 401 recoverable error using basic auth

I am using python jira client to establish a connection to jira using basic auth.

from jira.client import JIRA

jira = JIRA(options={'server': 'https://server.atlassian.net'},
            basic_auth=('[email protected]', 'pass'))

This code worked fine till yesterday.

Got recoverable error from GET https://server.atlassian.net/rest/api/2/serverInfo, will retry [1/3] in 17.5832343958s. Err: 401

My password and email is correct. I am able to login manually

Upvotes: 6

Views: 7875

Answers (3)

Mitch
Mitch

Reputation: 103

Basic authentication with passwords and cookie-based authentication no longer work since effectively 14 April 2019 for Jira and Confluence cloud - see deprecation notice. Api token needs to be used in place of passwords for basic_auth.

This snippet below should work:

from jira.client import JIRA

api_token = "***********************"
jira = JIRA(options={'server': 'https://server.atlassian.net'},
        basic_auth=('[email protected]', api_token))

I've also raised an issue in pycontrib/jira to reflect this: https://github.com/pycontribs/jira/issues/780.

Jira tickets to follow:

Upvotes: 6

Ulises
Ulises

Reputation: 1

It seems like passwords are being deprecated for the REST API. Perhaps this would help further: Atlassian Authentication

Upvotes: 0

Slo Learner
Slo Learner

Reputation: 58

Strange, might be security settings with HTTP vs HTTPS. Try passing to https instead of http.

from jira.client import JIRA

jira = JIRA(options={'server': 'https://server.atlassian.net'}, basic_auth=('[email protected]', 'pass'))

Upvotes: 0

Related Questions