Error message: Client must be authenticated to access this resource.,status-code:401

I used the python sample code provided in the link for get labels


it is showing error as “Client must be authenticated to access this resource”

Hi @RamachandranGunaseka,

Thanks for your message and welcome to Atlassian Developer Community! :partying_face:

You need to provide an API token in the sample code to authenticate your request. You need to change line 9 in the sample:

auth = HTTPBasicAuth("", "<api_token>")

Please read the following documentation if you wish to know more about basic HTTP authentication and API tokens:


@PawelCegla ,

I changed that before posting the query here. eventhough it shows the same error.


I’ve copied & pasted the code sample, changed lines 7 & 9 (url of the Jira Cloud site, user email & API token) and the sample worked fine:

    "isLast": true,
    "maxResults": 1000,
    "startAt": 0,
    "total": 3,
    "values": [

Please make sure that you changed, & <api_token> to correct values in the sample. Also can you check that the token you created at shows a recent “Last accessed” time after running the code sample?


Yes, I did the same but still showing the same error.

when i checked the token accessed, it shows last 4 mins ahgo.

@PawelCegla its working now. its my mistake, username typo error

Great news! :partying_face:

Happy coding!


Thanks @PawelCegla

Now i am facing when am using the JQL as below

{“errorMessages”:[“Field ‘labels’ does not exist or this field cannot be viewed by anonymous users.”],“warningMessages”:}

JQL query: query = {
‘jql’: ‘summary ~ ”CVE-2021-46143” AND status != Closed AND status != Done’

endpoint: url = “


I’ve been able to run the sample Python code from Search for issues using JQL (GET) without any issues.

This error message:

Field ‘labels’ does not exist or this field cannot be viewed by anonymous users.

suggests that this is again an authentication issue.

Are you sure you replaced, & <api_token> (lines 7 & 9 in the sample code) with proper Jira Cloud site URL, user email and API token values?


@PawelCegla thanks working fine.