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
I am using the same Client ID for getting authorized Code.
Please Help me what is Wrong.
$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.
-
364 Points
Posted 2 years ago
-
364 Points
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);
<?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);
Tyler Long, Official Rep
-
8,916 Points
Do you get the correct result? If no, what's the error message?
-
364 Points
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)
Tyler Long, Official Rep
-
8,916 Points
Why don't you use the official SDK instead? https://github.com/ringcentral/ringcentral-php
If you want to write your own, please reference https://github.com/ringcentral/ringcentral-php/blob/ac9984a8ae2e41239dfe84ae4f698f8a16b22417/src/Pla... and https://github.com/ringcentral/ringcentral-php/blob/ac9984a8ae2e41239dfe84ae4f698f8a16b22417/src/Pla...
If you want to write your own, please reference https://github.com/ringcentral/ringcentral-php/blob/ac9984a8ae2e41239dfe84ae4f698f8a16b22417/src/Pla... and https://github.com/ringcentral/ringcentral-php/blob/ac9984a8ae2e41239dfe84ae4f698f8a16b22417/src/Pla...
(Edited)
-
364 Points
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 ?
I am totally confuse what to do ?
Tyler Long, Official Rep
-
8,916 Points
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.
(Edited)
-
364 Points
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 .
Please help me .
Tyler Long, Official Rep
-
8,916 Points
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.
But first of all, I need to know what kind of problem are you having with the official SDK.
-
364 Points
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" } ] }
Tyler Long, Official Rep
-
8,916 Points
https://github.com/ringcentral/ringcentral-php/issues/39#issuecomment-242907546
If it is a web application, you cannot use the password flow.
Please use the authorization code flow instead. Demo code: https://github.com/ringcentral/ringcentral-demos-oauth/tree/master/php
Tutorial in Node.js: https://ringcentral-tutorials.github.io/authorization-code-flow-nodejs-express-demo/
If it is a web application, you cannot use the password flow.
Please use the authorization code flow instead. Demo code: https://github.com/ringcentral/ringcentral-demos-oauth/tree/master/php
Tutorial in Node.js: https://ringcentral-tutorials.github.io/authorization-code-flow-nodejs-express-demo/
(Edited)
-
160 Points
Refresh Token using sdk:
SDK sdk = new SDK( "ktx884**********-TL-O3Q",
"RNLRm1zYR**************4JxrC5CTjKpWF3KwRlFPg",
"https://platform.devtest.ringcentral.com";,
" ",
"");
Dictionary<string, string> obj = new Dictionary<string, string>();
obj.Add("refresh_token", CurrentUser.RCRefreshToken);
obj.Add("grant_type", "refresh_token");
var request = new Request("/restapi/oauth/token/",obj);
var responseToken = sdk.Platform.Post(request);
Getting Error:Access Expired
Can u please tell me.how can I refresh access token using Refresh Token Flow
SDK sdk = new SDK( "ktx884**********-TL-O3Q",
"RNLRm1zYR**************4JxrC5CTjKpWF3KwRlFPg",
"https://platform.devtest.ringcentral.com";,
" ",
"");
Dictionary<string, string> obj = new Dictionary<string, string>();
obj.Add("refresh_token", CurrentUser.RCRefreshToken);
obj.Add("grant_type", "refresh_token");
var request = new Request("/restapi/oauth/token/",obj);
var responseToken = sdk.Platform.Post(request);
Getting Error:Access Expired
Can u please tell me.how can I refresh access token using Refresh Token Flow
(Edited)
Tyler Long, Official Rep
-
8,916 Points
The sample code you post is not PHP. Could you please provide more information? If you tell me the programming language, I might be able to provide with you some sample code.
Tyler Long, Official Rep
-
8,916 Points
A new thread is preferred. Because this one is old and it's about PHP. I answered this question in another thread.
Related Categories
-
Getting Started
- 211 Conversations
- 74 Followers
-
SDKs
- 318 Conversations
- 100 Followers
-
APIs
- 848 Conversations
- 161 Followers
-
Environment (Sandbox, Gateway)
- 290 Conversations
- 93 Followers
-
Admin & Credentials
- 183 Conversations
- 44 Followers