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 in Python
Tags: getting started
Oct 8, 2018 at 2:26pm   •   10 replies  •  0 likes
rick-smith

Attempting to send SMS with python SDK I keep getting "Refresh Token has Expired "

How do I set this to never expire in Python, is it even possible? The documentation does not say.



10 Answers
answered on Oct 17, 2018 at 8:03am  
Tyler, I got it worjing! Thanks so much friend, you rock! Had to delete it and start from scratch but it works now! Again thanks 1000% for your patience!!

 0
answered on Oct 16, 2018 at 7:31am  
Hmm, well now Im getting
Exception: HTTP status code: 400

{
  "error" : "unauthorized_client",
  "error_description" : "Unauthorized for this grant type",
  "errors" : [ {
    "errorCode" : "OAU-251",
    "message" : "Unauthorized for this grant type"
  } ]
}
when I call rc.authorize('+NNNNNNN', '', 'password')
This is absurd I've done this with twilio send and receive in under 30mins...Not sure what the deal is but Im ready to cry uncle.



 0
answered on Oct 15, 2018 at 2:33pm  
Tyler forgot to include
rc.authorize("Username", "password")
Sorry about that.


 0
answered on Oct 12, 2018 at 7:22am  
Yes, I shortened it to this https://platform.ringcentral.com/restapi/v1.0/ as well as several other variations and no go? Any idea what its supposed to be? I got the above from ringcentrals own documentation?!? So either i'm reading it wrong, or they have another error. All this thing has to do is send an SMS.


 0
answered on Oct 11, 2018 at 7:07am  
Ok some progress
this
r = rc.post('https://platform.ringcentral.com/restapi/v1.0/account/1NNNNN/104/NNNNNNN/sms-log?dateFrom=2...', {
throws
Exception: HTTP status code: 404

  "errorCode" : "AGW-404",
  "message" : "Resource not found",

Thanks






 0
answered on Oct 10, 2018 at 6:00pm  
Hi Rick,

There are several users reported "Refresh Token has Expired" and they are not using Python at all. So I wonder this might be an issue from RC server side.

Could you please do me a favor? Try my Python SDK: https://github.com/tylerlong/ringcentral-python

By the way, there is a way to auto refresh the token: https://github.com/tylerlong/ringcentral-python#authorization-refresh

If you still have the issue, please post the code to reproduce the issue. By then we can confirm it is a RC server side issue or not.


 0
answered on Oct 10, 2018 at 10:18am  
Phong thanks again! Umm that does not work either, it throws same exception. Is any of this written down, anywhere? I'm trying the following:
 
   platform.auth().refresh_token()
 and or
platform.auth().data()
Does RC even work with python?




 0
answered on Oct 10, 2018 at 8:52am  
Hi Rick,

I don't use the Python SDK yet so I don't have exact code to show you. But I believe that after logged in, you can get the tokens info from the platform.auth().data(). When you need to refresh, just call platform.refresh() method.


 0
answered on Oct 10, 2018 at 5:33am  
Phong
Thanks for your assistance. How do I check the refresh token?

 0
answered on Oct 9, 2018 at 8:48am  
After successfully authenticated/logged in, your refresh token with expire in 7 days. Every time your access token expires, you can use the refresh token to request for a new access token. And every time you request for a new access token, the new refresh token expiration time will be set to 7 days again.

If the refresh token also expired, you must direct the user to the login page to login again.

Can you double check if the refresh token really expires or it's because of some bug in the Python SDK?

In this case, if the refresh token really expired after 7 days, you may need to implement a timer to check the expiration periodically and send a request for new access token when it nearly expires. That way you can always have a valid refresh token.

+ phong

 0



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