question

Philip Noble avatar image
Philip Noble asked ·

error" : "invalid_grant",errorCode" : "OAU-140", :Invalid Resource Owner Credentials

When I try to ping the URL using httprequest Iam hitting with error


below is the URL:

"https://platform.devtest.ringcentral.com/restapi/oauth/token?grant_type=password&username=180244XXXXX&password=VeXXXXXX&extension=101";

Method : POST

Header Key:

"Authorization" : "Basic OC1qb09WRThUdktQbHppNHdVbjJfdzpHT1ozWE5nblJ1MlhxZUV4dnphUXp3NkwycFFwVGhSWEdPYmwwd2poVkF2dw=="

"Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8"


Error :



400 Bad Request

{

"error" : "invalid_grant",

"errors" : [ {

"errorCode" : "OAU-140",

"message" : "Invalid resource owner credentials"

} ],

"error_description" : "Invalid resource owner credentials"

}


When I try give all above details in web API checker:

http://ringcentral.github.io/api-explorer/#!/Authentication/oauth_token_post

I am able to get the response.


Please let me know if am missing anything here.



invalid resource owner credentials
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered ·

These params need to be in the post body, not the url

grant_type=password&username=180244XXXXX&password=VeXXXXXX&extension=101"

Something like this in Node JS.

var basic = process.env.RC_CLIENT_ID + ":" + process.env.RC_CLIENT_SECRET;
var headers = {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Accept': 'application/json',
            'Authorization': 'Basic ' + Buffer.from(basic).toString('base64')
            };
var body = querystring.stringify({
              'grant_type' : 'password',
              'username' : encodeURIComponent(process.env.RC_USERNAME),
              'password' : process.env.RC_PASSWORD
            });


Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Philip Noble avatar image
Philip Noble answered ·

Thanks!!!

It Worked.

Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.