question

Dylon Price avatar image
Dylon Price asked Dylon Price commented

RingCentral.NET Mismatched Redirect URI error with matching URIs.

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.

rest api
1 |1500 characters needed characters left characters exceeded

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

Phong Vu avatar image
Phong Vu answered

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#

1 |1500 characters needed characters left characters exceeded

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

Dylon Price avatar image
Dylon Price answered Dylon Price commented

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


5 comments
1 |1500 characters needed characters left characters exceeded

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

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

1 Like 1 ·

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.

0 Likes 0 ·

Give it a little over an hour, and unfortunately I have the same result--OAU-109 error code.

0 Likes 0 ·

I have to trust the error message. Either the system still has not updated the app setting or there is a mismatch somewhere.

0 Likes 0 ·
Show more comments

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