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
404 AGW-404 from /restapi/v1.0/oauth/authorize
Tags: rest api, authentication
Nov 11, 2021 at 10:10am   •   1 replies  •  0 likes
Chris Thompson

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": []
}
1 Answer
answered on Nov 12, 2021 at 10:06am  

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


 0
on Nov 12, 2021 at 11:18am   •  0 likes

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.

on Nov 12, 2021 at 1:26pm   •  0 likes

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#

on Nov 15, 2021 at 5:54am   •  0 likes

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.



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