News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Access token corrupted in SMS API
Tags: sdk
Sep 1, 2017 at 9:29pm   •   2 replies  •  0 likes
airs-inc

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.







2 Answers
answered on Jul 4, 2019 at 1:25pm  

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


 0
answered on Sep 2, 2017 at 1:08am  
Please don't append a semicolon to the token and try again.
"Authorization: Bearer ".$access_token['access_token'].";"
==>
"Authorization: Bearer ".$access_token['access_token']

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us