Access token corrupted in SMS API

  • 1
  • Problem
  • Updated 1 year ago
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.
Photo of AIRS INC

AIRS INC

  • 160 Points 100 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 7,652 Points 5k badge 2x thumb
Please don't append a semicolon to the token and try again.
"Authorization: Bearer ".$access_token['access_token'].";"
==>
"Authorization: Bearer ".$access_token['access_token']
(Edited)