question

etam-singh8884 avatar image
etam-singh8884 asked Anirban answered

Authorization Code Flow.Geting Error (401) Unauthorized.

This is my code.I made a public sandbox account.Geting an error 401 unauthorized.


var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://platform.devtest.ringcentral.com/restapi/oauth/authorize");


httpWebRequest.Method = "GET";


httpWebRequest.Headers.Add("client_id", "DShb1**********2DlM5xoA");

httpWebRequest.Headers.Add("redirect_uri", "http://localhost:505471/");

httpWebRequest.Headers.Add("response_type", "code");

httpWebRequest.Headers.Add("state", "Client state");

httpWebRequest.Headers.Add("prompt", "login");



var httpresponse = httpWebRequest.GetResponse();

errorsauthentication
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
Can you let me know what type of RC app did you defined. Is your localhost on your local machine? And did you set the same redirect_uri's value to the "OAuth Redirect URI" field for your app?

Is there any reason you don't want to use our SDKs for your code?

+ Phong
1 |3000

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

etam-singh8884 avatar image
etam-singh8884 answered
Thanks for ur response Phong Vu.
Now I am using Ring Central sdk and I am able to authorize user  and get token in response.
1 |3000

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

Anirban avatar image
Anirban answered

Since the oauth type is Authorization code, make sure all the parameters are provided.

If you miss redirect uri parameter in request which is a mandatory part, you will unable to get token which is supposed to be exchanged with access token

1 |3000

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

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