question

Chris Thompson avatar image
Chris Thompson asked Chris Thompson commented

404 AGW-404 from /restapi/v1.0/oauth/authorize

I am attempting to convert from using application wide credentials for using the RingOut api to using individual user authentication, and I am running into two particular errors:

When using the RingCentral.Net v5.8.0 (+ RingCentral.Net.AuthorizeUri v1.0.0), the following code throws a NullReferenceException inside of RestClient.Request:

using (var rc = new RestClient(config.ClientId, config.ClientSecret, RestClient.SandboxServer))
{
 var redirectUri = config.RedirectUri;
 var loginLocation = await rc.Restapi().Oauth().Authorize().Post(
  new AuthorizeRequest()
  {
   response_type = "code",
   client_id = rc.clientId,
   redirect_uri = redirectUri,
  });
}

Stack trace:

   at RingCentral.RestClient.<Request>d__31.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RingCentral.RestClient.<Request>d__2.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RingCentral.RestClient.<Request>d__3`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RingCentral.RestClient.<Post>d__5`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at RingCentral.Paths.Restapi.Oauth.Authorize.Index.<Post>d__4.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

I have attempted to perform the same action using Postman, with a request looking like:


POST https://platform.devtest.ringcentral.com/restapi/v1.0/oauth/authorize
Authorization: Basic <"ClientId:ClientSecret" in Base64Url encoding>

Content-Type: application/x-www-form-urlencoded

response_type = code client_id = <Client Id> redirect_uri = <the same redirect uri>

But this constantly results in a HTTP 404 response:

{
 "errorCode": "AGW-404",
 "message": "Resource not found",
 "errors": []
}
rest apiauthentication
1 |3000

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

1 Answer

vyshakhbabji avatar image
vyshakhbabji Deactivated answered Chris Thompson commented

What is your ClientID? I need to check your app settings and verify if the settings are correct.

Here are some example samples for 3 legged oauth flow for your reference: https://github.com/ringcentral/ringcentral-demos-oauth\

and for c# https://github.com/ringcentral/ringcentral-demos-oauth/tree/master/csharp-nancy

https://github.com/ringcentral/RingCentral.Net/blob/master/RingCentral.Tests/AuthorizationTest.cs

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

Chris Thompson avatar image Chris Thompson commented ·

The ClientID for the sandbox account I have been testing with is NChGkWl9SK6PxDMTXQxDeg.

Looking at the AuthorizationTest file you linked to, the most similar scenario (for the login link) is actually commented out... I assume because it wasn't working?

What I have on the CSharp side looks practically identical to that example.

I have not yet gone through the other examples you linked to, because they appear to be for two other, deprecated, CSharp nuget packages for RingCentral.

0 Likes 0 ·
vyshakhbabji avatar image vyshakhbabji ♦♦ Chris Thompson commented ·

The OAuth redirect url that you are using in ur app doesn't look right to me. Please look into it and fix it.

Here is the full sample example code for handling 3-legged auth flow:
https://developers.ringcentral.com/guide/authentication/quick-start#c#

0 Likes 0 ·
Chris Thompson avatar image Chris Thompson vyshakhbabji ♦♦ commented ·

I made sure to copy the URL from the RingCentral config directly into the C# code as well as into Postman - I'm not noticing any differences between that value and what is set in the app settings.

Or is the value in the actual app settings itself invalid? If so, the only difference I am seeing between it and the example you refer to, is that it isn't using a direct port number, and it has a custom route instead of ending with /oauth2callback.

0 Likes 0 ·

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