question

Stephen Lee avatar image
Stephen Lee asked Tyler Liu commented

Error 400 on authentication

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?

call handling
1 |3000

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 Stephen Lee commented

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.

1 comment
1 |3000

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

Stephen Lee avatar image Stephen Lee commented ·

I tried again and still getting the same error!

0 Likes 0 ·
Stephen Lee avatar image
Stephen Lee answered

I got the same error today.

1667838716134.png


1667838716134.png (17.7 KiB)
1 |3000

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

Stephen Lee avatar image
Stephen Lee answered

Tested again today and got the same 400 error.

1 |3000

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

Stephen Lee avatar image
Stephen Lee answered Stephen Lee commented

Can anyone help me?

4 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.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Can you do the exact way as the sample code shows

RestClient rc = new RestClient("client_id", "client_secret", false);
0 Likes 0 ·
Stephen Lee avatar image Stephen Lee Phong Vu ♦♦ commented ·

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

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Stephen Lee commented ·

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

0 Likes 0 ·
Show more comments
Stephen Lee avatar image
Stephen Lee answered Tyler Liu commented

1668536922908.png


Code and error message.


1668536922908.png (46.1 KiB)
9 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.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Can you share the app client id here.

0 Likes 0 ·
Stephen Lee avatar image Stephen Lee Phong Vu ♦♦ commented ·

"0n-hWMbzS7KkBcwDCsC3lg"

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Stephen Lee commented ·

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#

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