News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
"Refresh token has expired" error message using PHP SDK and JWT
Tags: sdk
Apr 24, 2022 at 1:54pm   •   1 replies  •  0 likes
Rpbhoir30

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.

1 Answer
answered on Apr 24, 2022 at 11:06pm  

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!


 0
on Apr 26, 2022 at 6:35am   •  0 likes

Hi @Yatin Gera, Thanks for replaying back.

My SDK version is '2.2.3'; and i am creating fro sandbox account.

please refer attachment of JWT token, App, Code.

i have used $platform->login(['jwt' => 'Your JWT Token Here']);

and I am getting error 'Expected HTTP Error: Unauthorized for this grant type' and

Undefined array key "username" ,

Undefined array key "extension",

Undefined array key "password" and

PHP Warning: Array to string conversion in ../vendor/ringcentral/ringcentral-php/src/Platform/Platform.php on line 69

Let me know where i am doing wrong.



on Apr 26, 2022 at 9:17pm   •  0 likes

@Rpbhoir30 Phong pointed out the issue for you. Also, can you remove the screenshots from the post? There is some sensitive information as part of the screenshot and it would be better to not have it on a public forum. Thanks

on Apr 27, 2022 at 12:22pm   •  1 likes

@Yatin Gera just removed screenshot. thanks for informing.

on Apr 29, 2022 at 2:12am   •  0 likes

@Rpbhoir30 Were you able to use the new PHP SDK to get this working?

on Apr 26, 2022 at 7:39am   •  0 likes

Check the composer.json file and update your RingCentral PHP SDK. You need the latest version 2.3. Not the v2.2.3.



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us