Question

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

  • 11 November 2021
  • 2 replies
  • 899 views

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": []
}

2 replies

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

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.

Reply