I’m having trouble connecting to our company’s JIRA instance using the python-jira package. I keep getting a 401 unauthorized error when trying to authenticate with API tokens.
Here’s my current setup:
from jira import JIRA
connection = JIRA(
server='https://ourcompany.atlassian.net',
basic_auth=('[email protected]', 'api_token_here')
)
The error I’m seeing is:
WARNING:root:Got recoverable error from GET https://ourcompany.atlassian.net/rest/api/2/serverInfo, will retry [2/3] in 6.2s. Err: 401
This keeps retrying indefinitely until I stop it manually. I’ve already generated fresh API tokens since password authentication is deprecated. The credentials are definitely correct and I can use them successfully with curl commands.
Has anyone encountered similar authentication issues with the JIRA Python library? What alternative approaches should I consider?
Double check you’re using the right JIRA instance type in your connection setup. Corporate environments often need extra parameters like options={'verify': False} for SSL issues or specific auth headers. I hit the same 401 loop when our IT team had proxy settings that messed with API calls. Test your connection with a basic requests library call first - helps figure out if it’s python-jira specific or a general auth problem. Also check if your account has API access enabled in JIRA user settings. Sometimes the token works manually but doesn’t have programmatic access rights.
Had this exact problem for weeks! Turned out it was the server URL formatting. The python-jira library is super picky about trailing slashes and subdirectories in the server parameter. Try removing any trailing slash from your URL, or add one if it’s missing. Also check if your JIRA instance got migrated to a different subdomain - lots of companies change their Atlassian URLs during migrations. Another thing that trips people up is using personal email addresses when your org requires specific domain formatting. Ask your JIRA admin what authentication format they want for API access.
i had this problem too. make sure the api token is correct and not expired. sometimes url changes can mess things up too. hope it helps!