Forums

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

Error: Client must be authenticated to access this resource.

Tobi Akinyemi
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!
July 27, 2020

I'm requesting to `https://{site}.atlassian.net/rest/agile/1.0/board/{board}/issue` with the header `Authorization: Basic base64encodedToken`. However I'm getting the error.

The base64 encoded string is of: `username:api-token` I also tried `email:api-token` - neither work.

Does anyone know the issue here?

What's weird is I can access `https://{site}.atlassian.net/rest/api/latest/issue/{issueId}` with no authentication (it's /api instead of /agile). The documentation uses /api and /agile interchangeably with no explanation of the difference

 

1 answer

0 votes
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 29, 2020

Hello @Tobi Akinyemi ,

Thanks for reaching out, and the first point I would like to provide clarification on is yor question on the interchangeability of rest/api and rest/agile in the endpoint paths.  This comes down to The variations in the applications.  Jira comes in three different packages, Core, Software, and Service Desk, and theses differences in the api are in relation to how Core functionality is at the base application layer and the additional Software agile and service desk related features are built on top of the core application and the /agile endpoints are functionality specific to the additional functions of Jira Software,  and the additional endpoints related to Jira service desk specific functions API endpoints which are represented with a /rest/servicedeskapi path.

So when you are calling  on "GET /rest/api/3/issue/{issueIdOrKey}" you are interacting with the Core platform API  and when calling "GET /rest/agile/1.0/board/{boardId}/issue" you are interacting with the Jira Software API and then there is also the additional Service Desk API as well if you are also running this third Jira option.

Next looking at the call "GET /rest/agile/1.0/board/{boardId}/issue" , you noted, the error you recieved indicates a issue in the authentication.   I ran a test on my instance using a base64 encoded "email:apitoken" in the following format on a board with an id of  "rapidView=1" and everything went through without issue 200 OK:

curl -D- -X GET -H "Content-Type: application/json" -H "Authorization: Basic <BASE64_encoded_useremail:token_here>" --URL 'https://<base_url>.atlassian.net/rest/agile/1.0/board/1/issue'

So, I am wondering if you are possibly running into an issue with the base64 encoding formatting itself, as if this was an issue with permissions on the instance as noted in the API documentation for the endpoint:

Note, if the user does not have permission to view the board, no issues will be returned at all.

There are some examples of the formatting to use in this KB for the Base64 encoding at the section noting that you do want to use the format of "useremail:api_token":

If you need to, you may construct and send basic auth headers yourself. To do this you need to perform the following steps:

  1. Generate an API token for Jira using your Atlassian Account: https://id.atlassian.com/manage/api-tokens.
  2. Build a string of the form useremail:api_token.
  3. BASE64 encode the string.
    • Linux/Unix/MacOS:
      echo -n user@example.com:api_token_string | base64
    • Windows 7 and later:
      $Text = ‘user@example.com:api_token_string’
      $Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)
      $EncodedText = [Convert]::ToBase64String($Bytes)
      $EncodedText
  4. Supply an Authorization header with content Basic followed by the encoded string. For example, the string fred:fred encodes to ZnJlZDpmcmVk in base64, so you would make the request as follows:
curl -D- \
-X GET \
-H "Authorization: Basic ZnJlZDpmcmVk" \
-H "Content-Type: application/json" \
"https://your-domain.atlassian.net/rest/api/2/issue/QA-31"

Additionally to test the validity of the API token against the base64 encoded value to make sure that there is nothing erring there try a call without using base64 and pass the useremail:api_token value directly like the following example to see if the authentication is valid without the encoded value:

curl -D- -u useremail:API_Token -X GET -H "Content-Type: application/json" https://<Base_URL>.atlassian.net/rest/agile/1.0/board/1/issue

Let me know what you find.

Regards,
Earl

Tobi Akinyemi
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!
July 30, 2020

Hi Earl,

I was able to use the following endpoint - without any authentication

<base_url>.atlassian.net/rest/api/latest/search

According to what you were saying, I don't think the agile api was the correct one for the board I'm querying

 

Thanks for the informative answer

Like Earl McCutcheon likes this
Earl McCutcheon
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 30, 2020

Hello @Tobi Akinyemi ,

Looking at  "GET /rest/api/3/search" as noted in the documentation:

This operation can be accessed anonymously.

Noting that a 200 OK should be returned regardless of the issues returned, however the issues that are returned will be based on the authorization level of the user making the call per project permissions, so only issues that you have permission to view are returned by this call and no results will return if you are not authorized but the response should be a 200 OK regardless, noting:

 Issues are included in the response where the user has:

So if you are making an anonymous call to the endpoint and returning values it indicates that you have anonymous access enabled on the project.

Regards,
Earl

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events