Forums

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

401 Client Error on Api Token authentication with requests

Simon König
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 12, 2024

Hi,

I am currently trying to access our server via Rest API V2 via python.

To do this I followed

https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/#get-an-api-token

and specifically for python:

https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#about.

 

Now I already got some things working (a simple GET Issue request did just fine) but am now puzzled: I tried to implement a simple check with:

https://your-domain.atlassian.net/rest/api/2/myself on startup.

My header consists of:

{"Content-Type": "application/json"} and my auth = HTTPBasicAuth(email, api_token)
FYI: We (have to) use a self signed SSL Zertificate, thats why I used verify=False in my requests.
And even though I get Issue information, the check returns a 401 error and I can not find a Error in my script.

 

1 answer

0 votes
Florian Bonniec
Community Champion
March 12, 2024

Hi @Simon König 

 

You tag this post as Data Center but you are referencing Cloud documentation.

Are you using Cloud or Data Center ?

Regards

Simon König
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2024

Hi, sorry for the confusion. I am using DataCenter. I used another authentication and constructed my header with:

 

    def headers(self):
        return {"Authorization": f"Bearer {self.api_token}"}

Suggest an answer

Log in or Sign up to answer