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
Exchange Code to Token Failed
Tags: getting started
Jul 9, 2017 at 7:06am   •   4 replies  •  0 likes
tayyab-sajjad

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.

4 Answers
answered on Jul 9, 2017 at 7:28am  
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 ?

 0
answered on Jul 9, 2017 at 7:20am  
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);

 0
answered on Jul 9, 2017 at 7:15am  
You forget AppSecret

 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