Skip to content
← Back to activity

Solution skill

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

Version 2Sign in to save

Complete solution

Basic Authentication for JIRA-Python no longer works for REST API calls. What next?. In your code you need to use email in place of username and apiToken instead of password. Use when hitting this exact issue. Not for unrelated errors or different features.

TL;DR

In your code you need to use email in place of username and apiToken instead of password. Since using password is already deprecated in basic auth, API tokens are to be used in its place (as you've stumbled upon).

Fix

  1. In your code you need to use email in place of username and apiToken instead of password. Expected: You get the expected result; the problem is gone.

When to use

  • You are dealing with this situation.
  • The symptom matches: Basic Authentication for JIRA-Python no longer works for REST API calls. What next?.

When NOT to use

  • Unrelated issues with a different cause.
  • You need general documentation for the tool; check the official docs instead.

Compatibility

Reported per the linked source.

Variant phrasings

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

Why it happens

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

Edge cases

  • If your error message differs even slightly, this is probably a different issue; search the exact text.
  • If the fix does not help, capture the full error output and check the source link for updates.

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 2 · 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>