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
Java SDK Subscription Refresh Causing 401 Error
Tags: sdk
May 28, 2019 at 4:22pm   •   1 replies  •  0 likes
Super Admin

I'm able to successfully create a new subscription using the Java SDK, but when the subscription attempts to refresh itself it's failing with a 401 error. Either there is a bug with the Java SDK or I'm missing something.

When the subscription is created, it starts a timer to regularly refresh itself:

https://github.com/ringcentral/ringcentral-java/blob/master/src/main/java/com/ringcentral/Subscription.java#L89


Bug when this code runs:

https://github.com/ringcentral/ringcentral-java/blob/master/src/main/java/com/ringcentral/Subscription.java#L110


This error results:

com.ringcentral.RestException: HTTP status code: 401


{

"errorCode" : "TokenInvalid",

"message" : "Token not found",

"errors" : [ {

"errorCode" : "OAU-213",

"message" : "Token not found"

} ]

}

at com.ringcentral.RestClient.request(RestClient.java:152)

at com.ringcentral.HttpClient.put(HttpClient.java:43)

at com.ringcentral.HttpClient.put(HttpClient.java:77)

at com.ringcentral.Subscription.refresh(Subscription.java:115)

at com.ringcentral.Subscription$2.run(Subscription.java:94)

at java.util.TimerThread.mainLoop(Timer.java:555)

at java.util.TimerThread.run(Timer.java:505)


Am I doing something wrong or is this an issue with the SDK?


1 Answer
answered on May 29, 2019 at 10:35am  

Hi Dan,

Yes, the subscription object renews (refresh) the PubNub notifications automatically. It uses the RestClient object, which uses the access token to renew the subscription periodically.

The RestClient is also, by default, auto-refresh, which uses the refresh token to request for a new access token if the access token expires.

In your case, it could be either, the refresh token is also expired if you ran your app for more than a week, which may not be likely the situation. Or, somehow, the access token was revoked.

I ran my test code for a few hours and the notification works fine.

Can you double check, make a simple test and let me know.


 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