question

Rpbhoir30 avatar image
Rpbhoir30 asked Yatin Gera Deactivated edited

"Refresh token has expired" error message using PHP SDK and JWT

I am new to RingCentral and using the JWT auth method.

I have followed the instructions in your developer guide (https://developers.ringcentral.com/guide/authentication/jwt-flow) regarding JWT authentication. I am trying to get an access token but am getting the error:

Expected HTTP Error: Refresh token has expired

Here is my code

Screen Shot 2022-04-24 at 4.51.48 PM.png

My client id - RQzC-BTETXqUOVyl_sUHsw'

Please help me. I don't know what I am doing wrong.

sdk
1 |3000

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

1 Answer

Yatin Gera avatar image
Yatin Gera Deactivated answered Rpbhoir30 rolled back

When making a post request, you might want to make sure the content type in the header is set to application/x-www-form-urlencoded and you are URL encoding the value for urn:ietf:params:oauth:grant-type:jwt-bearer properly.

The PHP SDK comes with jwt support so the easiest way would be to leverage that and let the SDK do this for you.

All you need to do is use the login function and pass your jwt token to it:

 $platform->login(['jwt' => 'Your JWT Token Here']);
  • Make sure that the JWT token you are using is generated for the correct environment (sandbox/production)

  • Make sure your PHP SDK is updated to at least version 2.3.0

Kindly accept the solution if you find this useful so that others can benefit from the same. Cheers!

1 |3000

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

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