question

alexey-shpilka avatar image
alexey-shpilka asked ·

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?
topic-default
1 |1000 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 ·
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 Share
1 |1000 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,

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 Share
1 |1000 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 ·
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 Share
1 |1000 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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.