Basic Auth for atlassian.net domain when using python library stopped working a few days ago.

Rudiger Wolf April 24, 2019

Hi

My code to get data out via the Jira cloud API did not change, last week it still worked. In the past few days it stopped working. I have tested two different accounts on atlassian.net domain. Neither work.

I have also tested this code against two self hosted Jira installations and it works.

I see some information about API's changing, but I am not sure what I should do to get accounts on atlassian.net  working again.

I am using python. Any suggestions?

 

from jira.client import JIRA
from dynaconf import settings

# Basic Auth problem on atlassian.net domain.

USERNAME = settings.JIRA_USERNAME # os.environ["JIRA_USERNAME"]
USER_PASSWORD = settings.JIRA_PASSWORD #os.environ["JIRA_PASSWORD"]
SERVER_URL = settings.JIRA_DOMAIN #os.environ["JIRA_DOMAIN"]

options = {
'server': SERVER_URL,
'verify': True,
'basic_auth': (USERNAME, USER_PASSWORD),
}
jira = JIRA(options=options, basic_auth=(USERNAME, USER_PASSWORD))

# print all of the project keys as an example
for project in jira.projects():
print(project.key)

 

1 answer

1 accepted

John Fetzik
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.
April 24, 2019

Yes, use of passwords has been deprecated.

Alex Christensen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 24, 2019

Came here to post this. :) Some of my own users are also facing this, I believe, except with Confluence.

alexbenfica April 11, 2020

@Rudiger Wolf  do you have it working on a .atlassian.net domain?

Did you have to do any configuration to enable the rest API?

Rudiger Wolf April 12, 2020

@alexbenficayes, it was on the dot net url.

I don't recall having to enable API.

alexbenfica April 13, 2020

@Rudiger Wolf can you share which version of the Python JIRA lib you are using?

Thanks a lot for your answer on this!

Rudiger Wolf April 13, 2020

@alexbenfica 

I just created a python 3.8.2 project

Installed libraries

pip install jira dynaconf

created settings.toml file with

[default]
JIRA_PASSWORD='XXXXXXX'
JIRA_USERNAME='first.last@xxxx.com'
JIRA_DOMAIN='https://xxxxx.atlassian.net

Note that the password is NOT your regular password. It is the token created at https://id.atlassian.com/manage-profile/security/api-tokens

Here is a list of all the versions of installed libraries

(.venv) C:\Users\rnwol\workspace\testjiraaccess> pip freeze
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
click==7.1.1
cryptography==2.9
defusedxml==0.6.0
dynaconf==2.2.3
idna==2.9
jira==2.0.0
oauthlib==3.1.0
pbr==5.4.5
pycparser==2.20
PyJWT==1.7.1
python-box==3.4.6
python-dotenv==0.12.0
requests==2.23.0
requests-oauthlib==1.3.0
requests-toolbelt==0.9.1
six==1.14.0
toml==0.10.0
urllib3==1.25.8

If you need to you might also install the development version of jira from master which is

pip install git+https://github.com/pycontribs/jira.git@856d6241f0e59be7da76f4287e83717fe7541b0a

as at 14 April 2020.

alexbenfica April 14, 2020

Thank you very much for sharing. I am using the same version.

I managed to have it working with this code below.

import os
from base64 import b64encode
import pprint
from jira import JIRA

JIRA_CLONER_VERSION = '2.0'

print('Using JIRA server {} with username {}'.format(
os.environ.get('JIRA_SERVER'),
os.environ.get('JIRA_EMAIL')
))

to_encode = '{}:{}'.format(os.environ.get('JIRA_EMAIL'), os.environ.get('JIRA_API_TOKEN'))
encoded_auth = b64encode(bytes(to_encode, 'utf-8')).decode('utf-8')

options = {
'server': os.environ.get('JIRA_SERVER'),
'rest_api_version': 2,
'headers': {
'Authorization': 'Basic {}'.format(encoded_auth),
'Content-Type': 'application/json',
},
}


jira = JIRA(options=options)
Like Rudiger Wolf likes this

Suggest an answer

Log in or Sign up to answer