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
Invalid resource owner credentials when using access token
Tags: credentials
Jan 21, 2022 at 10:24am   •   2 replies  •  0 likes
Nirmal Babu

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?

2 Answers
answered on Jan 24, 2022 at 7:49am  

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.


 0
on Jan 24, 2022 at 8:42am   •  0 likes

Thanks @Phong Vu

answered on Jan 21, 2022 at 11:10am  

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


 0
on Jan 21, 2022 at 11:28am   •  0 likes

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.

on Jan 23, 2022 at 7:41pm   •  0 likes

Hi @Nirmal Babu
Could you please share your code here so that we can see what is happening?

on Jan 23, 2022 at 8:02pm   •  0 likes

Hi @Yatin Gera

RestClient restClient = new RestClient(clientId,clientSecret, server);

token = getAccessToken from DB - for rcId

if(token == null or createdTime> 60mins) {

    TokenInfo ti = restClient.authorize(rcId, ext, password);

    save -> token = ti.access_token

    save -> createdTime = Calendar.getInstance().getTime()

}

else{

    TokenInfo ti = new TokenInfo();

    ti.access_token(token);

    restClient.token = ti;

}




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