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
Error 400 on authentication
Tags: call handling
Nov 4, 2022 at 3:57pm   •   5 replies  •  0 likes
Stephen Lee

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?

5 Answers
answered on Nov 15, 2022 at 10:29am  

1668536922908.png


Code and error message.


 0
on Nov 15, 2022 at 10:36am   •  0 likes

Can you share the app client id here.

on Nov 16, 2022 at 9:04am   •  0 likes

"0n-hWMbzS7KkBcwDCsC3lg"

on Nov 16, 2022 at 10:18am   •  0 likes

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.

screen-shot-2022-11-16-at-101135-am.png

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#

on Dec 13, 2022 at 2:59pm   •  0 likes

Thank you. I will take a look.

on Nov 21, 2022 at 12:34pm   •  0 likes

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.

on Nov 21, 2022 at 1:22pm   •  0 likes

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#

on Nov 22, 2022 at 4:10pm   •  0 likes

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


on Dec 13, 2022 at 5:01pm   •  0 likes

@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?

on Dec 14, 2022 at 9:24am   •  1 likes

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);
on Dec 14, 2022 at 2:59pm   •  0 likes

I think I got it working. Thank you for your help.

on Nov 22, 2022 at 9:54am   •  0 likes

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.

on Nov 22, 2022 at 11:59am   •  0 likes

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.

on Nov 17, 2022 at 1:47pm   •  0 likes

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.

answered on Nov 10, 2022 at 8:03am  

Can anyone help me?


 0
on Nov 11, 2022 at 11:05am   •  0 likes

Can you do the exact way as the sample code shows

RestClient rc = new RestClient("client_id", "client_secret", false);
on Nov 14, 2022 at 5:55pm   •  0 likes

When I changed the client id and secret to the default values, the "rc.Authorize" line threw an Object reference not set.... exception.

on Nov 14, 2022 at 8:09pm   •  0 likes

What do you mean the default values? They must be your app client id and client secret for the sandbox environment.

on Nov 15, 2022 at 10:24am   •  0 likes

I think you meant using "false" as the third parameter. Yes, I tried that and got the same result.

answered on Nov 8, 2022 at 12:36pm  

Tested again today and got the same 400 error.


 0
answered on Nov 7, 2022 at 7:19am  

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.


 0
on Nov 11, 2022 at 10:16am   •  0 likes

I tried again and still getting the same error!

answered on Nov 7, 2022 at 8:32am  

I got the same error today.

1667838716134.png


 0



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