Skip to main content

Getting Invalid resource owner credentials error regularly after some time when using acesss tokens to authorize ringcentral user. We are getting the access tokens by authorizing using grant_type=password. And are reusing the same access tokens for the next 1 hr to make API calls and then re generate tokens.


Using ringcentral java SDK version 1.4.0

We are facing this with ringcentral production credentials

@Phong Vu could you please help in finding the root cause?

When you get such an error, you need to trust the error message. There are many possible mistakes that cause the problem.

static String RINGCENTRAL_CLIENT_ID_PROD = "production app client id";
static String RINGCENTRAL_CLIENT_SECRET_PROD = "production app client secret";
static String RINGCENTRAL_SERVER_PROD = "https://platform.ringcentral.com";

static String RINGCENTRAL_USERNAME_PROD = "some production username";
static String RINGCENTRAL_PASSWORD_PROD = "some production user password";
static String RINGCENTRAL_EXTENSION_PROD = "some production user extension number";

static String RINGCENTRAL_CLIENT_ID_SANDBOX = "sandbox app client id";
static String RINGCENTRAL_CLIENT_SECRET_SANDBOX = "sandbox app client secret";
static String RINGCENTRAL_SERVER_SANDBOX = "https://platform.devtest.ringcentral.com";

static String RINGCENTRAL_USERNAME_SANDBOX = "some sandbox username";
static String RINGCENTRAL_PASSWORD_SANDBOX = "some sandbox user password";
static String RINGCENTRAL_EXTENSION_SANDBOX = "some sandbox user extension number";

static RestClient restClient;


public static void main(String[] args){
try {
restClient = new RestClient(RINGCENTRAL_CLIENT_ID_PROD, RINGCENTRAL_CLIENT_SECRET_PROD, RINGCENTRAL_SERVER_PROD);
restClient.authorize(RINGCENTRAL_USERNAME_PROD, RINGCENTRAL_EXTENSION_PROD, RINGCENTRAL_PASSWORD_PROD);
...

If you mix any of the parameters between the production and sandbox, you would end up in such an error. Many developers make such a mistake when they don't change the username, password and extension number properly.

Double check, try again and let me know


Hi @Phong Vu we are using correct parameters only

The issue is, it is working for some time later on it throws invalid resource credentials error and after some time again it works fine.

Earlier we used to authorize every single time to send an SMS, didnt have any issues then except for the rate limit exceeded

Only change is now, we are using access tokens and are reusing them(until they expire which is for 1 hr and regenerate again) to authorize and then send SMS.


So when it fails, it fails in this loop, right?

if(token == null or createdTime> 60mins){
TokenInfo ti = restClient.authorize(rcId, ext, password);
...

There is a reason to double check (at least print it to the console so you can see it) if rcId, ext and password are the same as when you first login.

I don't know how you save the token into a db and what is the primary key. The name "rcId" sound like an account Id rather than a username to me.


Reply