question

airs-inc6788 avatar image
airs-inc6788 asked ·

Access token corrupted in SMS API

Hi Ringcentral,

I use Ring central SMS API in PHP. I got message " Access token corrupted" when I try to send SMS. I searched for this but not found any solution.

My application is in under development mode.

Here is my code:
function send_sms(){
                 

$credential = get_access_token();
$access_token = refresh_access_token($credential['refresh_token']);

if(isset($access_token['error']) && $access_token['error']!=''){
echo $access_token['error_description'];
}
else{

$url = "https://platform.devtest.ringcentral.com/restapi/v1.0/account/177248004/extension/101/sms";
$header = array("Accept: application/json;","Authorization: Bearer ".$access_token['access_token'].";","Content Type: application/json;");
$sms_data = json_encode(array("from"=>array("phoneNumber"=> RC_FROM_PHONE_NUMBER),"to"=>array(array("phoneNumber"=> $_POST['phone'])),"text"=>trim($_POST['message'])));

$objCCurl = new CCurl();
$data = $objCCurl->curl_request($url,'POST',$sms_data,$header,false,false);

if(isset($data['errorCode']) && $data['errorCode']!=''){

$err = $data['errorCode'];
if(isset($data['message']) && $data['message']!=''){
$err .= ' - '.$data['message'];
}
}
else{
//success
}


}


}

OUTPUT :

{ "errorCode" : "TokenInvalid", "message" : "Access token corrupted", "errors" : [ { "errorCode" : "OAU-129", "message" : "Access token corrupted" } ] }


Please let me know how to resolve this error.

Thanks in advance.






General Topic
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered ·
Please don't append a semicolon to the token and try again.
"Authorization: Bearer ".$access_token['access_token'].";"
==>
"Authorization: Bearer ".$access_token['access_token']
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban avatar image
Anirban answered ·

As pointed, a small typo mistakes in your code will lead to different type of issue or exceptions.

Make sure you check all these in your code before querying in forum and remove it

1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.