Question

Can not change refresh_token

  • 23 May 2018
  • 3 replies
  • 1756 views

Hello, i use the library https://github.com/ringcentral/ringcentral-php.

$apiResponse = $rcsdk->platform()->post('/restapi/oauth/token', [
    'refresh_token' => $data['refresh_token'],
    'grant_type' => 'refresh_token',
    'endpoint_id' => $_ENV['RC_AppKey']

]);


I get a response from the server, Unsupported grant type. What is the problem?


3 replies

Userlevel 1
Hi Alexey,

Why do you want to change the refresh token? After logged in, if the access token expired, you can call $rcsdk->platform()->refresh() to refresh the access token. If the refresh token also expired, you just need to call $rcsdk->platform()->login($option) again.

You can always check if the access token and the refresh token is still valid or not to decide what to do by calling $rcsdk->auth()->accessTokenValid() or $rcsdk->auth()->accessTokenValid(), respectively.

+ Phong
Alexey,

Can you verify that your app has the "Refresh Access Token" flow grant which is required to refresh your token? I will look like the following in the "Settings" > "OAuth Settings" > "Authorization Flows" section of your app configuration as shown below:



Thanks,
John
Instead of the code you post, could you please try '$rcsdk->platform()->refresh()' instead? Because the PHP SDK already provides method for refreshing.

Reply