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)
OK I think I have found the answer. In summary I need to use api-tokens instead of the password.
https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/
https://confluence.atlassian.com/cloud/api-tokens-938839638.html
Yes, use of passwords has been deprecated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Came here to post this. :) Some of my own users are also facing this, I believe, except with Confluence.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Rudiger Wolf do you have it working on a .atlassian.net domain?
Did you have to do any configuration to enable the rest API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Rudiger Wolf can you share which version of the Python JIRA lib you are using?
Thanks a lot for your answer on this!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.