question

alexey-shpilka10314 avatar image
alexey-shpilka10314 asked Tyler Liu commented

Can not change refresh_token

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?

errors
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.

Phong Vu avatar image
Phong Vu answered alexey-shpilka10314 commented
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
1 comment
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.

We need automation of the process, is it possible to authorize without entering a username and password?
0 Likes 0 ·
John Wang avatar image
John Wang answered alexey-shpilka10314 commented
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
1 comment
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 Tyler Liu commented
Instead of the code you post, could you please try '$rcsdk->platform()->refresh()' instead? Because the PHP SDK already provides method for refreshing.
37 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.

Because you haven't got the token yet. So you cannot call refresh.

'->authUrl()' method return an URL, it doesn't do authorization at all.
1 Like 1 ·
thanks, helped, I thought I was already authorized
1 Like 1 ·
Login developer.ringcentral.com, go to your RingCentral app, navigate to Settings tab. And search for "Authorization Flows". There should be "Authorization code flow", otherwise your code won't work. 

You can create a new app and make it support Authorization code flow.
1 Like 1 ·
I don't have the permission to delete either. I will turn to my colleagues for help. They live in different time zone so maybe they won't respond in several hours.

You should just change your password for security.

I will find some one to edit the password message but you have to wait.
1 Like 1 ·
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