I am attempting to connect to our Jira setup using the Python JIRA Package. Here’s the code I’m using:
from credentials import *
import requests
from jira import JIRA
jira = JIRA(server='https://myjirainstallation.com/jira', basic_auth=('[email protected]', 'MyAccessToken'))
print(jira.projects())
However, when I execute this code, I encounter the following error:
HTTPError 401
Unauthorized (401)
Basic Authentication Failure - Reason: AUTHENTICATED_FAILED
I can log in successfully through the web interface.
hve you tried using api token instead of password? sometmes regular password doesn’t work. Log in to jira, generate a token and use that as a password, it might fix ur issue!
The issue you’re facing might relate to how security settings are configured on your Jira server. If you’re using a company-managed Jira, sometimes an additional step is needed. Make sure that your access token is linked to the IP address you’re connecting from. Additionally, check with your Jira admin if there are any firewall restrictions or if two-factor authentication is enabled, as these might prevent successful connections using basic authentication. Updating to the latest version of the Python JIRA library might also help resolve some authentication issues.
If using the API token or addressing potential firewall and security settings didn’t help, you should ensure that the base URL is correct. Pay attention to the server URI, sometimes missing subdomain like /jira
or extra path identifiers can cause problems. Check if there’s a proxy or VPN that you might be using which could affect the connection as well. Additionally, printing more debug info from the requests module might provide more clues as to what is going wrong during the authentication attempt.
Another potential solution to consider is checking your local environment variables or how your system manages network connections. Sometimes, the operating system or other applications might be overriding certain default settings, causing issues with your requests. Confirm that there are no overriding proxies, incorrect DNS configurations, or restrictive firewall settings on your machine. Additionally, secure connections from behind a VPN might sometimes require special configuration, so ensure the VPN settings are aligned with your server’s requirements.