I followed the code example at https://developers.ringcentral.com/guide/voice/ringout#c# but getting error 400 on the "Authorize" line.
One or more errors occurred. (Call failed with status code 400 (Bad Request): POST https://platform.devtest.ringcentral.com/restapi/oauth/token).
Here is code:
static RestClient restClient;
static void Main(string[] args)
{
restClient = new RestClient("client-id",
"client-secret",
"https://platform.devtest.ringcentral.com/");
restClient.Authorize(
"+1470502xxxx",
"101",
"XXXXXXX").Wait();
call_ringout().Wait();
}
Can you tell me what did I do wrong?
Code and error message.
Can you share the app client id here.
"0n-hWMbzS7KkBcwDCsC3lg"
Hmm, you application auth type is 3-legged authorization and you are trying to authenticate with password flow and that is why you always failed.
Create a new app and choose Password flow type instead. Remember that a password flow app is supported only for Private app. If you do need your app to be a public app and use authorization code as your current app. You will need to implement 3-legged authorization.
Read these dev guides to understand more about authentication modes
https://developers.ringcentral.com/guide/authentication/auth-code-flow
https://developers.ringcentral.com/guide/authentication/quick-start#c#
Thank you. I will take a look.
Hi Phong. Just want to confirm, is it true that only stations from our own organization (based on the client ID) can make outgoing calls if I use the username and password authentication flow? Our application is a dotNET Framework 4.6 Windows application, do you have code sample for the 3-legged flow? All I need to be able to do is ring out. Thank you.
I really don't understand your question. What are the "stations from your organization"? Who is going to use your app? What is the purpose (use case) for you to use the ring-out API?
I post the sample code for 3-legged auth in my previous answer https://developers.ringcentral.com/guide/authentication/quick-start#c#
The SDK is .NET standard 2.0 compliant which works for both .NET core and .NET framework.
However the 3-legged oauth demo is indeed in .NET core.
If your app is a desktop app instead of a website, maybe this demo is more suitable: https://github.com/tylerlong/windows-form-ringcentral-oauth-demo
@Tyler Liu I was able to retrieve the access token with your sample app. Thank you. Now I need to know how to make an out going call with that access token. Can you point me to the appropriate documentation?
If you want to do ring out, check here: https://github.com/ringcentral/RingCentral.Net/blob/master/samples.md#createringoutcall
since you already have the token, you only need this line:
var result = await rc.Restapi(apiVersion).Account(accountId).Extension(extensionId).RingOut().Post(makeRingOutRequest);
I think I got it working. Thank you for your help.
Our company uses RingCentral as our phone system. I created the app in the developer console using my user account. When you said the password flow app is supported only for private app, does that mean only users within our RingCentral account can use it?
The code sample in your link was written using .NET Core. So I wanted to find out if you have sample written in regular .NET framework.
Private app: Only users under the account that owns the app can have access.
Private app & password flow auth: Only the user whose username and password are used to authenticate the app can use the app. Normally this is a server app that does something for the entire company such as reading the company call logs and create call reports etc. provided that the user has the admin role to access company call logs. This cannot be used for app that provides personal service such as sending SMS, making calls or access user private data.
Private app & 3-legged auth: Any user under the account can login the app (e.g. a web app) and use it. E.g. send and receive SMS messages.
Public app: All users under any RingCentral account can access the app.
Public app & password flow auth: Not supported as every user will use the app on behalf of the user whose username and password are used to authenticate the app. E.g. everyone can send SMS from that user's phone number!!! Forbidden right?
Public app & 3-legged auth: Any user can login the app with their own login credentials to use the app.
In your case, ask the question "who is going to use the app?", Can any user use the app w/o login with their own credentials? For making a /ring-out purpose, the "from" and the "to" number can be any number, but the user who is authenticated the app will own that call. In the case of a password flow auth, if you allow anyone in the company to use the app, that's fine but the call will be owned solely by the authenticated user.
Unfortunately, we don't have a .NET framework SDK.
We have a Windows based CRM software and I have customers requesting to add a RingCentral dialer from within our app. So we will need to be able to authenticate using both 3-legged and password flow. Thank you for the help.
Can anyone help me?
Can you do the exact way as the sample code shows
RestClient rc = new RestClient("client_id", "client_secret", false);
When I changed the client id and secret to the default values, the "rc.Authorize" line threw an Object reference not set.... exception.
What do you mean the default values? They must be your app client id and client secret for the sandbox environment.
I think you meant using "false" as the third parameter. Yes, I tried that and got the same result.
There was an outage during the weekend on sandbox server. Can you try again and let me know.
BTW, I edited your question to hide app client id and client secret as well as the phone number.
I tried again and still getting the same error!
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