I know that it was discussed before, but I don't see any solution for this error :
{"message":"Client must be authenticated to access this resource.","status-code":401}%
I'm not working with UI ( User Interface) and I am working from backend, I want to authenticate myself (my users) to be able to run some API call.
I want to run this code :
curl --request GET \
--url 'https://MYSITE.atlassian.net/rest/api/3/applicationrole' \
--header 'Accept: application/json'
or in python :
import requests
import json
url = "https://MYSITE.atlassian.net/rest/api/3/applicationrole"
headers = {
"Accept": "application/json"
}
response = requests.request(
"GET",
url,
headers=headers
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
But I'm getting this error :
{"message":"Client must be authenticated to access this resource.","status-code":401}%
the question is how to authenticate it before or at same time (in same line) ?
Hi @Maziar Sojoudian ,
of course you are getting 401, there is no authentication header in your request.
I know you said username:password is not working anymore, but it does... so maybe you did something wrong.
Note that username:password need to be encoded in base64, so for example:
useradmin:passadmin = "dXNlcmFkbWluOnBhc3NhZG1pbg==" (and this is what you need to put in your authentication header).
You said you are working with python, so your request should be like that:
import requests
url = "https://MYSITE.atlassian.net/rest/api/latest/........."
payload = ""
headers = {
'Authorization': "Basic dXNlcmFkbWluOnBhc3NhZG1pbg=="
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)
I"m using the Basic authentication, but it looks like the response depends on the URL (i.e. the resource) I'm using..
Does anybody knows if I can use the same credentials I use to access Jira Service Desk or do I need to create a special user for API access?
Do I need to provide the user with special access privileges?
Does also the "expansion" of the JSON response depends on the user privileges?
Cheers,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
did you find the answer?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maziar
did you already have a look to the https://developer.atlassian.com/server/jira/platform/basic-authentication/
there is explained how to use Basic Auth etc.
curl -u username:password -X GET -H "Content-Type: application/json" http://localhost:8080/rest/api/2/issue/createmeta
Cheers
Kurt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Either you use username:password and if that does not work you can use a token based approach
https://confluence.atlassian.com/cloud/api-tokens-938839638.html
see also the answer from Nir
Cheers
Kurt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.