News & Announcements User Community Developer Community

Welcome to the RingCentral Community

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

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:

Bug when this code runs:

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(

at com.ringcentral.HttpClient.put(

at com.ringcentral.HttpClient.put(

at com.ringcentral.Subscription.refresh(

at com.ringcentral.Subscription$

at java.util.TimerThread.mainLoop(


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.


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

Developer Platform
Integrated Apps
App Gallery
Developer support
Games and rewards

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