Authenticating with Jira API using Python: Bypassing MFA

Hey everyone, I’m struggling with Jira API authentication in Python. I used to be able to log in fine, but after enabling two-factor auth, I’m hitting a snag.

My old code looked something like this:

if api_key:
    jira_client = JiraConnection(
        server=jira_server,
        auth_token=api_key
    )

I thought API tokens were supposed to skip MFA, but now the auth step just hangs. Anyone else run into this? How did you solve it? I’ve been googling for hours and can’t find a clear answer.

Any tips or tricks would be super helpful. Thanks in advance!

I encountered a similar issue when implementing Jira API authentication in Python. In my experience, switching to a Personal Access Token (PAT) rather than using an API key resolves the authentication hang you described. You can generate a PAT by logging into your Atlassian account and navigating to the Security section to create a new API token specifically for your Python script. Once generated, update your code to use basic authentication with your email and new token. This method effectively bypasses MFA and should address the problem.

hey mate, ran into this myself. make sure ur using the right api token - not the old one. generate a new token in jira settings (account settings > security > create api token). then use that in ur code. shud work without mfa hassle. good luck!

I’ve dealt with this exact issue recently when our company rolled out MFA. The key is to use a Personal Access Token (PAT) instead of your regular API key. What helped me was going to Atlassian Account Settings, then navigating to Security where you can create and manage API tokens. I generated a new token specifically for my script and then used that token in my code instead of the old API key. Also, make sure you are using the latest version of the Jira Python library since older versions sometimes have issues with the new authentication methods. If you’re still having problems, check your Jira server URL carefully to avoid simple typos. I hope this helps you get unstuck.