Private API Token Authentication Documentation

  • 1
  • Question
  • Updated 1 month ago
I have not been able to find the documentation as to how to authenticate using Private API Token.
The only thing I can find is: 
  1. Once you have an approved API key, use the Private API Token, along with the Client ID and Client Secret, to sign your API requests.
No matter how I try to use that I get  {"error":"invalid_token","error_description":null} which is absolutely not helpful.
Please provide details and an example of how to use this feature.
Photo of Roger Johnsen

Roger Johnsen

  • 2 Posts
  • 0 Reply Likes
  • frustrated

Posted 8 months ago

  • 1
Photo of Bradford Shannon

Bradford Shannon, Employee

  • 5 Posts
  • 3 Reply Likes
Roger,

When using the Private Token method of authentication, the Private API token needs to be encoded using BASE64 encoding.

This can be done with your own scripts, or with the use of a free BASE64 encoding tool. Once you have an Encoded Key, you will need to include the encoded Private API token in your header of any API you are making.

Your Header should look like Key= Authorization, and your Value = BasicEncodedKey
Photo of abdul hannan

abdul hannan

  • 10 Posts
  • 0 Reply Likes
Hi Bradford,
I have still getting error..
$curl = curl_init();

$token = base64_encode('here is my token');

curl_setopt_array($curl, array(
CURLOPT_URL =>"https://api.rightsignature.com/public/v1/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING =>"",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST =>"GET",
CURLOPT_HTTPHEADER => array(
"authorization: 'Basic ' + $token",
"cache-control: no-cache",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

response: 
{"error":"invalid_token","error_description":null}
Photo of Roger Johnsen

Roger Johnsen

  • 2 Posts
  • 0 Reply Likes
Thank you for your quick response.

It made no difference though, we are still getting the same result.  Since we cannot find any documentation for this anywhere, we have no way of telling what we are doing wrong.

This is our code (php):

$curl = curl_init();

$token = base64_encode('MY_TOKEN');

curl_setopt_array($curl, array(
 CURLOPT_URL =>"https://api.rightsignature.com/public/v1/me";,
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING =>"",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 30,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST =>"GET",
 CURLOPT_HTTPHEADER => array(
"authorization: $token",
"cache-control: no-cache",
 ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
 echo "cURL Error #:" . $err;
} else {
 echo $response;
}

And the response is :  {"error":"invalid_token","error_description":null} 
Photo of MLC

MLC

  • 2 Posts
  • 2 Reply Likes
I'am also getting the same error. @Roger, have you resolved this issue?
Photo of MLC

MLC

  • 2 Posts
  • 2 Reply Likes
@Roger, Please add 'Basic ' before your base64Encoded Token. like this - "authorization: 'Basic ' + $token", [add a space after basic]
(Edited)
Photo of abdul hannan

abdul hannan

  • 10 Posts
  • 0 Reply Likes
hi MLC, 
I have still getting error..
$curl = curl_init();

$token = base64_encode('here is my token');

curl_setopt_array($curl, array(
CURLOPT_URL =>"https://api.rightsignature.com/public/v1/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING =>"",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST =>"GET",
CURLOPT_HTTPHEADER => array(
"authorization: 'Basic ' + $token",
"cache-control: no-cache",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}

response: 
{"error":"invalid_token","error_description":null}
Photo of Kelly Leeman

Kelly Leeman, Employee, Software Engineer

  • 63 Posts
  • 5 Reply Likes
Can you please double check your token?  The one you posted in your other post is invalid.
Photo of abdul hannan

abdul hannan

  • 10 Posts
  • 0 Reply Likes
My problem is resolve, the error is single quotes on Basic. so the request make an error.
Photo of Kelly Leeman

Kelly Leeman, Employee, Software Engineer

  • 63 Posts
  • 5 Reply Likes
The above is correct there should be a space between the word Basic and your encoded token.
Photo of Lucian Cazaciuc

Lucian Cazaciuc

  • 1 Post
  • 0 Reply Likes
Many thanks @MLC.
it works!
(Edited)
Photo of Shahin Ahmed

Shahin Ahmed

  • 16 Posts
  • 1 Reply Like
Hi, i was having

{"error":"invalid_token","error_description":null}

after going through this post i've corrected the request script. but now i'm having:

{"status":500,"error":"Internal Server Error"}

i'm using the same script as mentioned above and encode my API key. And give space between basic and token as suggested.
 
      $curl = curl_init();

$token = base64_encode('PRIVATE API TOKEN');

curl_setopt_array($curl, array(
CURLOPT_URL =>"https://api.rightsignature.com/public/v1/me";,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING =>"",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST =>"GET",
CURLOPT_HTTPHEADER => array(
     "authorization: Basic +$token",
     "cache-control: no-cache",
),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;

}
Any help would appreciable. Thanks in advance.
(Edited)
Photo of Shahin Ahmed

Shahin Ahmed

  • 16 Posts
  • 1 Reply Like
Hi i just resolved the issue :)
Photo of Tushar M

Tushar M

  • 7 Posts
  • 0 Reply Likes
How you have soled your issue.Can you guide me?? @Shahin Ahmed