API Authentication failing

Asiya Yunusa May 22, 2023

Hello, I am trying to authenticate to my accounts API endpoint bit it keeps failing.

IO have used the Basic AUTH (HTTPBasicAuth) and Bearer Token (Header Authentication Method) methods but they both are not working.

 

Please can I get some input.

 

Thank you 

1 answer

1 accepted

1 vote
Answer accepted
Oliver Siebenmarck _Polymetis Apps_
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.
May 22, 2023

 

Hi @Asiya Yunusa ,

Welcome to the community!

Without the actual error message you're getting it is a bit hard to pin point the actual problem. However, here are a couple things you might want to check:

The error message you should be getting will have much more information on what is happening, so if you can share that, we should be able to give you more specific hints.

Best regards,
 Oliver

Asiya Yunusa May 22, 2023

Thank you!

This is the error from Postman using the Bearer Token: 

{
"error": "Failed to parse Connect Session Auth Token"
}

Yes, I am using the toke generated from my account.

 

I am trying to authenticate to Confluence cloud

 

The screenshot is how I am trying to authenticate with BasicAuthconf.png 

I can curl from my terminal and it is successful with

curl -v https://mysite.atlassian.net --user me@example.com:my-api-token
Oliver Siebenmarck _Polymetis Apps_
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.
May 22, 2023

Hi @Asiya Yunusa ,

I'm not that big of an expert in Python, but I believe your code does not actually sends your credentials to Confluence. Here's what should work:

 

EMAIL = "YOU-EMAIL"
TOKEN = "YOUR-TOKEN"

url = "https://YOUR-SITE.atlassian.net/wiki/api/v2/spaces/SPACEID/pages/PAGEID"
auth = HTTPBasicAuth(EMAIL, TOKEN)

headers = {
"Accept": "application/json"
}

response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Hope that helps,
 Oliver
Asiya Yunusa May 22, 2023

Thank you! :) It working now

 

Asiya

Taha Siddiqui November 28, 2023

Hi!

@Oliver Siebenmarck _Polymetis Apps_ I am facing the same problem in javascript I tried with Basic token and also with Bearer token but none of them work. Can you please help me with that.

Oliver Siebenmarck _Polymetis Apps_
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.
November 28, 2023

Hey @Taha Siddiqui ,

The first thing to check would always be the error message you're getting, just because so many different things can go wrong. What kind of error message/code does the API return?

Taha Siddiqui November 28, 2023

@Oliver Siebenmarck _Polymetis Apps_  Now I am using the different approach. My requirement is that I have organization ID and API token and I want to use organization API but I don't have access token how can I create it I tried but it didn't work I am linking the picture. Can you please help me with that?


image.png

 

I am giving organization Id in place of client id and API token in place of client secret

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events