question

airs-inc6788 avatar image
airs-inc6788 asked Anirban answered

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.







sdk
1 |1500 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 |1500 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 |1500 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.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys