question

sumit-agarwal34 avatar image
sumit-agarwal34 asked vyshakhbabji Deactivated answered

OAuth authentication API

Hey, I am trying to get the access token and refresh token. I am sending the request using curl. I have followed all the steps written in API docs. The response I am getting is

{

"error" : "invalid_grant",

"error_description" : "Invalid resource owner credentials."

}


Can u tell me what's wrong with that ????


Thank You!!!

developer sandboxlog in
1 |3000

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

ringcentral35 avatar image
ringcentral35 answered
"invalid_grant
The provided authorization grant (e.g., authorization
code, resource owner credentials) or refresh token is
invalid, expired, revoked, does not match the redirection
URI used in the authorization request, or was issued to
another client.
" I found this document, hope it helps:

http://oauthlib.readthedocs.org/en/la...
1 |3000

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

vyshakhbabji avatar image
vyshakhbabji Deactivated answered

This error indicates that the user credentials provided are improper, e.g. username, extension, and/or password.

Below is information on getting your proper credentials in the Sandbox Environment and Production Environment.

1) Sandbox Environment User Credentials

If you are on Sandbox Environment,  follow the below steps to get your sandbox account credentials:

  1. Login to https://developer.ringcentral.com/ using your Developer Platform credentials (RC account credentials)
  2. Go to your Sandbox Account page: "My Account > Sandbox Account". Locate the "Main Company Number" which will be your username when formatted in E.164 format, (example: +12223334444).  
  3. The password is the password you received via email when you created the sandbox account, unless you have changed the password.
The above credentials can also be used for logging into, and reset at, the Online Account Portal for Sandbox Environment at:  https://service.devtest.ringcentral.com/

In addition to your user credentials, you need to ensure you are connecting to the correct Sandbox API end point and using the correct application credentials described below:
  1. For sandbox environment, the API sever end endpoint URI is  https://platform.devtest.ringcentral.com 
  2. Find your application key and secret by clicking on My Account -> Applications -> Application Name. Use Sandbox Application key and secrets

The easiest way to start testing our APIs would be by using our  API Explore here  http://ringcentral.github.io/api-explorer/. You can start filling out your RC sandbox credentials and start going from there. We have self explanatory documentation in the link above.

2) Production Environment

If you are on Production Environment, follow the below steps to get your production account credentials:

  1. The user credentials for production are the same ones as for your RingCentral phone account that you use, e.g. to log into the Online Account Portal at https://service.ringcentral.com.
In addition to your user credentials, you need to ensure you are connecting to the correct Production API end point and using the correct application credentials described below:
  1. For production environment, the sever end endpoint uri is  https://platform.ringcentral.com 
  2. Find your application key and secret by clicking on My Account -> Applications -> Application Name. Use Production Application key and secrets

For more information please visit this link: https://developer.ringcentral.com/library/tutorials/test-account.html

1 |3000

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

sumit-agarwal34 avatar image
sumit-agarwal34 answered
Hey VB,

Thanks for the reply. I have got the acces token. Now, I am trying to make a ringout call using the ringcentral API. The request body I am passing is like this :

{  "to": {"phoneNumber": "91*******"},
  "from": {"phoneNumber": "91*******"},
  "callerId": {"phoneNumber": "91*******"},
  "playPrompt": true
}

The response I am getting is : 

{ "message": "Forbidden", "errorCode": "InternationalProhibited" }

The same call when I try to make with the ringcentral account is successful. Can u tell me what's wrong with that. 
1 |3000

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

naveen-sanjeeva16509 avatar image
naveen-sanjeeva16509 answered
International calling is not supported in the Sandbox. Please use US local numbers or numbers on your test account to place calls to verify your code. This will work as expected in Production provided the accounts you use there have the right privileges and credits to make international calls.
1 |3000

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

andrei-t4438 avatar image
andrei-t4438 answered
Hi - i do provide all the correct information, but still get this error. what could i possibly be doing wrong? this is a sandbox account

1 |3000

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

andrei-t4438 avatar image
andrei-t4438 answered
On top of that, i am unable to login with my 'main' account number auto-generated when i opened up a sandbox account.

https://service.devtest.ringcentral.com/#/number

but it works with the email option
1 |3000

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

andrei-t4438 avatar image
andrei-t4438 answered
It stops working the moment i switch the app type to 'server only'
1 |3000

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

vyshakhbabji avatar image
vyshakhbabji Deactivated answered

Can you send us an email or open a support ticket?

1 |3000

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

sushil-kumar6908 avatar image
sushil-kumar6908 answered
Hello,

I want to use Ringcentral Ringout call in my app. I follow  https://developer.ringcentral.com/api-explorer/latest/index.html#/RingOut 

But, I am unable to login through CURL. Please assist how can I login through CURL



1 |3000

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

ak avatar image
ak answered sushil-kumar6908 commented
Hi Sushil,

Before you login, could you please check if the Application type = Private and Platform Type = Server-only ( NO UI ). 

As all other application types would need Authorization Code Flow or commonly known as OAuth2.0 as the authentication flow. However, if your application is of the above mentioned type then you can use the Password Flow as the authentication flow.

However, I would recommend you take a look at our dev community article below on how to login ( get tokens ) through cURL:
https://devcommunity.ringcentral.com/ringcentraldev/topics/curl-command-for-requesting-access-token
6 comments
1 |3000

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

sushil-kumar6908 avatar image sushil-kumar6908 commented ·
Hello AK,

Thanks for your reply!

I tried, followed by https://devcommunity.ringcentral.com/ringcentraldev/topics/curl-command-for-requesting-access-token . However, I got
{
  "error" : "invalid_request",   "error_description" : "Unsupported grant type" 
}

Please help me out this.
0 Likes 0 ·
ak avatar image ak commented ·
Can you provide the name of your app on Developer portal?

Additionally, you can take a look at this community article where another developer faced a similar issue and they were able to fix the issue. 
https://devcommunity.ringcentral.com/ringcentraldev/topics/unauthorized-for-this-grant-type-error
0 Likes 0 ·
sushil-kumar6908 avatar image sushil-kumar6908 commented ·
Hello AK,

My developer app name is  Sushil. what is the difference between grant_type password and login password.

I am stuck on this. Please help me out.

Thanks
0 Likes 0 ·
sushil-kumar6908 avatar image sushil-kumar6908 commented ·
I am using CURL PHP. Here is the code.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, " https://platform.devtest.ringcentral.com/restapi/oauth/token;");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=+19045591288&password=XXXXX&extension=101&grant_type=XXXXX");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "XXXXXXw0H8R2mUjiky28mElw" . ":" . "vOh9QIsYQRScrVRGn-GF9ACY-izpBITMC7SN8jjXXXXX");

$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
   echo 'Error:' . curl_error($ch);
}

echo '<pre>';
print_r($result);
curl_close ($ch);

I want to make call using Ringout. I follow  https://developer.ringcentral.com/api-explorer/latest/index.html#/RingOut 

When I make Authorize and Ringout Call then I got "Inprogress" status. I want to implement it in my custom code. However, I need "access_token", so I tried above script for login and get access_token. But I get error.

Kindly check and help me out.

Thanks :)
0 Likes 0 ·
sushil-kumar6908 avatar image sushil-kumar6908 commented ·
Hello Ak,

Hope you understand my requirement. I am still waiting for your positive response.

Thanks
0 Likes 0 ·
Show more comments

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys