question

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 asked Tyler Liu commented

Exchange Code to Token Failed

This is my Code for getting token.

$code=$_REQUEST['code'];

$APPKEY="u8hj81KeQ9uQDyA1PBTTgw";

$req='https://platform.devtest.ringcentral.com/restapi/oauth/token';

$post = array (

'grant_type' => 'authorization_code',

'code' => $code ,

'redirect_uri' => 'http://localhost/token.php');


$ch = curl_init($req);


curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


$apiKey = base64_encode($APPKEY);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

'Authorization: Basic ' . $apiKey,

'Accept: application/json',

'Content-Type: application/x-www-form-urlencoded'));


curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);



$response = curl_exec($ch);

curl_close($ch);

$r=json_decode($response, true);






And the Response is

array (size=3)    'error' => string 'invalid_client' (length=14)    'error_description' => string 'Invalid client: ' (length=16)    'errors' =>       array (size=1)        0 =>           array (size=3)            'errorCode' => string 'OAU-153' (length=7) 

'message' => string 'Invalid client: ' (length=16)




I am using the same Client ID for getting authorized Code.

Please Help me what is Wrong.

getting started
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
You forget AppSecret
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.

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered tayyab-sajjad6063 commented
Now look this is correct ?
<?php


$code=$_REQUEST['code'];
$APPKEY="u8hj81KeQ9uQDyA1PBTTgw";
$req=' https://platform.devtest.ringcentral.com/restapi/oauth/token';
$post = array (
'grant_type' => 'authorization_code',
'code' => $code ,
'client_secret', => 'l_IDw9I3QgW1zirl_PlqoQmLJM4Df2TCOBeN5FcF8_lQ',
'redirect_uri' => ' http://localhost/token.php&client_id=u8hj81KeQ9uQDyA1PBTTgw');

$ch = curl_init($req);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$apiKey = base64_encode($APPKEY);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . $apiKey,
'Accept: application/json',
'Content-Type: application/x-www-form-urlencoded'));

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


$response = curl_exec($ch);
curl_close($ch);
$r=json_decode($response, true);
var_dump($r);
2 comments
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.

Do you get the correct result? If no, what's the error message?
0 Likes 0 ·
i am getting this response ..

array (size=3)   'error' => string 'invalid_client' (length=14)   'error_description' => string 'Invalid client: ' (length=16)   'errors' =>      array (size=1)       0 =>          array (size=3)           'errorCode' => string 'OAU-153' (length=7)           'message' => string 'Invalid client: ' (length=16)           'parameters' =>  
array (size=1) 
0 Likes 0 ·
Tyler Liu avatar image
Tyler Liu answered
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.

tayyab-sajjad6063 avatar image
tayyab-sajjad6063 answered Tyler Liu commented
When i use the official SDK i am getting grant issue because i am trying to make a web application.
I am totally confuse what to do ?
9 comments
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.

If you have problem using the official SDK, you should post the problem here instead of writing your own solution. Because your own solution will have that grant issue too.
0 Likes 0 ·
After a lot of struggle i am trying to write my own code, because ringcentral developer email is not replying to my problem .
Please help me .
0 Likes 0 ·
Just post the problem in the devcommunity and you will get the help as soon as we see it. Probably much faster than the email help. Here is the preferred place for us to help developers.

But first of all, I need to know what kind of problem are you having with the official SDK.
0 Likes 0 ·
Auth exception: Refresh token has expired Exception: Unauthorized for this grant type SDK HTTP Error at https://platform.devtest.ringcentral.com/restapi/oauth/token Response text: { "error" : "unauthorized_client", "error_description" : "Unauthorized for this grant type", "errors" : [ { "errorCode" : "OAU-251", "message" : "Unauthorized for this grant type" } ] }
0 Likes 0 ·
Show more comments

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