I'm working on developing an integration with RingCentral's API and am using the RingCentral.NET nuget package, along with the AuthorizeUriExtension.
When attempting to call authorizeUriExtension.BuildUri(), I'm passing in the AuthorizeRequest object as expected, and filling that with a redirect uri. As this integration is currently in development, I am using ngrok to tunnel to localhost and give the API something to redirect to. Code sample below for this call.
// NOTE: _rc below is my restClient variable from RingCentral.NET public string GetLoginUrl() { var authorizeUriExtension = new AuthorizeUriExtension(); _rc.InstallExtension(authorizeUriExtension); return authorizeUriExtension.BuildUri(new AuthorizeRequest { redirect_uri = "https://[randomNgrokStringHere].ngrok.io/Home/Index" }); }
On attempting this call, however, I get an error back about there being a mismatch between the redirect_uri value that I'm sending, and the Redirect URI in App > Settings > OAuth Redirect URI--even though the Redirect URI in settings is character for character identical.
I will note that previously I was having no issues with this, and all of a sudden despite the matching URI it is suddenly throwing errors that they do not match.
Hi @Phong Vu!
Well, this worked with ngrok previously--so I'm unsure why it would suddenly not be. However, I did just test by changing to using localhost as my callback (and updating both my code and the uri in the settings page for my app) and was greeted by the same error. Error text is below.
{ "error" : "invalid_grant", "errors" : [ { "errorCode" : "OAU-109", "message" : "Redirect URIs do not match" } ], "error_description" : "Redirect URIs do not match" }
As a sanity check, I've attached a screenshot of both the code calling the sdk, and the relevant setting.
It would take some time to get the new redirectUri in effect. Try it again in an hour or so.
Give it a little over an hour, and unfortunately I have the same result--OAU-109 error code.
I have to trust the error message. Either the system still has not updated the app setting or there is a mismatch somewhere.
Good morning!
Apologies for the delay--I was out sick yesterday. You were correct that the system had just not updated, after logging in this morning I was able to connect correctly using localhost as my uri. Appreciate your help in pointing me in that direction! Previously it had updated fairly quickly, so I was quite confused as to why all of a sudden nothing was working. I'll mark your answer as accepted.
Thanks!
Sounds good, I will try again in an hour! Previously with ngrok I had multiple hours between tests, but I'll try that again just using localhost.
You don't need to use ngrok tunnel for your test app redirectUri. If you run it locally, use localhost with your own port number. Make sure to change the redirectUri in your app settings. E.g.
"http://localhost:5000/oauth2callback";
https://developers.ringcentral.com/guide/authentication/quick-start#c#
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