Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

401 Unauthorized Error with API Token (Bearer) in Jira Data Center

JHON VIDAL FIGUEROA CESPEDES
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 14, 2025

Hi community,

I'm trying to connect to the REST API of our Jira Data Center instance (https://jira.globaldevtools.bbva.com) using a Python script, but I'm stuck on a persistent authentication error.

My account has two-factor authentication (MFA) enabled.


 

What I've tried so far:

 

 

1. Basic Authentication (Failed)

 

My first attempt was to use basic_auth with my email and an API Token. This failed with a 403: Basic Authentication has been disabled on this instance error, which is expected.

 

2. Bearer Token Authentication (Failed)

 

Following best practices, I changed my connection method in Python to use a Bearer Token in the headers. The code is as follows:

Python
from jira import JIRA

jira_server = 'https://jira.globaldevtools.bbva.com'
api_token = 'MY_NEWLY_GENERATED_API_TOKEN'

headers = {
    'Authorization': f'Bearer {api_token}'
}

jira = JIRA(server=jira_server, options={'headers': headers})

However, this results in a 401 Unauthorized: Client must be authenticated to access this resource error.

 

3. Regenerating Tokens

 

I have revoked and regenerated the API Token multiple times, copying it very carefully to ensure it is correct, but the result is always the same 401 error.

 

4. Testing with cURL (Outside of Python)

 

To rule out an issue with the Python library, I made a direct request using curl from my terminal. The result was identical:

Bash
curl --request GET \
  --url 'https://jira.globaldevtools.bbva.com/rest/api/2/myself' \
  --header 'Authorization: Bearer MY_NEWLY_GENERATED_API_TOKEN' \
  --header 'Accept: application/json'

Response: {"message":"Client must be authenticated to access this resource.","status-code":401}


 

My Question:

 

Given that Basic Authentication is disabled and Bearer authentication with a freshly generated API token fails in both Python and curl, what server-side Jira configurations could be causing this consistent rejection?

  • Is there a specific user-level or group-level permission that my account needs to have in order to use the REST API?

  • Could this be related to an IP Allowlist that is blocking requests from external services like Google Colab (where I am running the script)?

  • Are there any other recommended authentication methods for corporate instances with MFA that I should consider?

Any guidance would be greatly appreciated, as I have exhausted the client-side solutions. Thank you!

1 answer

0 votes
Jack Dillon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 14, 2025

Hi @JHON VIDAL FIGUEROA CESPEDES 

 

There are no specific user-level or group-level permissions that you need to interact with the API. For example, if your user can create an issue in Jira through the browser than you can create an issue using the rest API as long as you provide the same credentials.

"Could this be related to an IP Allowlist that is blocking requests from external services like Google Colab (where I am running the script)?"  This sounds like it could be the issue, especially since you are on data center, I would check with your infrastructure team to see if there are any restrictions in place to prevent this connection. One thing you could try is pinging your Jira server from the environment where you are running your code. 

What API endpoint are you sending a request to? I would try one that you are guaranteed to have access to, like getting a specific issue that you have verified you can view in the broswer. Hope this helps some :)

 

Thanks,

Jackson

 

Suggest an answer

Log in or Sign up to answer