Skip to main content

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.

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#


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.
2021-05-14-13-42-32-ringcentralapitest-microsoft-v.png

2021-05-14-13-42-58-ringcentral-developers.png


It would take some time to get the new redirectUri in effect. Try it again in an hour or so.


Reply