Forums

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

Receive 401 - Unauthorized Error Message even credential is proper for authcode

savani.shailesh
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!
June 19, 2019

$issueid = "DM-27093";

$url = "https://wellnessliving.atlassian.net/rest/api/3/issue/".$issueid;
$headers = array("Authorization: Basic {authcode}");
// Here authcode = base64_encode(username:password)

$curl = curl_init();
if($headers){
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
$curl_response = curl_exec($curl);
curl_close($curl);

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 20, 2019

Hi @savani.shailesh ,

Are you actually base64 encoding the string username:password (as I can read in the provided example) or email-address:api-token in order to authenticate your REST API calls?

If you are trying to use your password instead of an Api Token then this is failing because basic authentication has been deprecated, as announced long time ago: Deprecation notice - Basic authentication with passwords and cookie-based authentication

 

In case you are already using an API token to authenticate, then can you kindly try to perform the same call using Postman or Curl (example provided below) and see if this works? In case  this will fail as well, please paste the command and the output (removing the sensitive data) in your  reply:

curl -D- -u EMAIL-ADDRESS:API-TOKEN https://wellnessliving.atlassian.net/rest/api/3/issue/DM-27093

 

For example, against my test instance:

curl -D- -u xxxxxxxx@atlassian.com:xxxxxxxxxxxx https://xxxxxxxx.atlassian.net/rest/api/3/issue/TSP-21


HTTP/2 200
server: AtlassianProxy/1.15.8.1
vary: Accept-Encoding
cache-control: no-cache, no-store, no-transform
content-type: application/json;charset=UTF-8
strict-transport-security: max-age=315360000; includeSubDomains; preload
date: Thu, 20 Jun 2019 10:26:43 GMT
atl-traceid: af596f516b1ca785
x-aaccountid: 557057xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x-arequestid: a431fbf3xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x-xss-protection: 1; mode=block
timing-allow-origin: *
x-content-type-options: nosniff
set-cookie: atlassian.xsrf.token=BAL3-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path=/; Secure


{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"10524",..........

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events