Confluence-cloud Rest API returns 401 Unauthorize while fetching space with access token

kuldeep kushwaha October 28, 2019

Hi,

I have created an access token using the below-mentioned link

https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/

When I use this access token along with confluence REST API to ge space data the error I receive is

{ "statusCode": 401,

"data": { "authorized": false, "valid": true, "errors": [], "successful": false },

"message":"com.atlassian.confluence.api.service.exceptions.AuthenticationRequiredException: Authentication is required"

}

below mentioned is request object

{

method: 'GET',
url: 'https://<domain>.atlassian.net/wiki/rest/api/space',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: 'Bearer <access_token>'

}

}

Can some one please help me with this.

1 answer

5 votes
Krister Broman _Advania_
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.
October 29, 2019

Try this 

  1. Create an API key: https://id.atlassian.com/manage/api-tokens#

  2. Combine the key with login name in base64 string, go to https://www.base64encode.org/ 
  3. Format is loginname:API-key exampel: krister.broman@advania.se:ABCDE12345 give result: a3Jpc3Rlci5icm9tYW5AYWR2YW5pYS5zZTpBQkNERTEyMzQ1
  4. Combine this with the authentication type in the below case a basic so the full text is: Basic a3Jpc3Rlci5icm9tYW5AYWR2YW5pYS5zZTpBQkNERTEyMzQ1 

Example from Postman:

postman.png

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events