Skip to content
← Back to activity

Immutable solution version

Basic Authentication for JIRA-Python no longer works for REST API calls. What next?

Version 1Sign in to save

Complete solution

Since using password is already deprecated in basic auth, API tokens are to be used in its place (as you've stumbled upon). In your code you need to use email in place of username and apiToken instead of password. In your code it should be # jira = JIRA(server, basic_auth = (my_JIRA_username, my_JIRA_pass)) jira = JIRA(server, basic_auth = (email, apiToken)) Try it out and do tell us how it goes.

Since using password is already deprecated in basic auth, API tokens are to be used in its place (as you've stumbled upon). In your code you need to use email in place of username and apiToken instead of password. In your code it should be # jira = JIRA(server, basicauth = (myJIRAusername, myJIRApass)) jira = JIRA(server, basicauth = (email, apiToken)) Try it out and do tell us how it goes.

Context: Stack Overflow question (score 2, has accepted answer): In Python, I used to be able to authenticate with JIRA over REST using a simple bit of code: from jira import JIRA myJIRAusername = 'myname' myJIRApass = 'mypassword' server = {'server': 'https://mysite.atlassian.net'} jira = JIRA(server, basicauth = (myJIRAusername, myJIRApass)) And then be able to do something simple like: myissue = jira.issue('MYISSUE-1') print myissue.key But JIRA has changed things, and I am guessing no longer allows basic authentication like this via the REST API. Instead I get a 401 error. I tired creating an API token, as suggested here: https://confluence.atlassian.com/cloud/api-tokens-938839638.html except I have NO idea where to use it (it doesn't work if I just use it as a password, like in the code above). I looked into OAuth as an alternative bu

Evidence

Stack Overflow question (score 2, has accepted answer): In Python, I used to be able to authenticate with JIRA over REST using a simple bit of code: from jira import JIRA myJIRAusername = 'myname' myJIRApass = 'mypassword' server = {'server': 'https://mysite.atlassian.net'} jira = JIRA(server, basicauth = (myJIRAusername, myJIRApass)) And then be able to do something simple like: myissue = jira.issue('MYISSUE-1') print myissue.key But JIRA has changed things, and I am guessing no longer allows basic authentication like this via the REST API. Instead I get a 401 error. I tired creating an API token, as suggested here: https://confluence.atlassian.com/cloud/api-tokens-938839638.html except I have NO idea where to use it (it doesn't work if I just use it as a password, like in the code above). I looked into OAuth as an alternative bu Resolved: Since using password is already deprecated in basic auth, API tokens are to be used in its place (as you've stumbled upon). In your code you need to use email in place of username and apiToken instead of password. In your code it should be # jira = JIRA(server, basicauth = (myJIRAusername, myJIRApass)) jira = JIRA(server, basicauth = (email, apiToken)) Try it out and do tell us how it goes. Source: https://stackoverflow.com/questions/56710224/basic-authentication-for-jira-python-no-longer-works-for-rest-api-calls-what-ne

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_dHYT0s1R0h5aAgkkOmYFvg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Basic Authentication for JIRA-Python no longer works for REST API calls. What next? <span>— Vectle</span></a>