Search code examples
c#asp.net-mvcgoogle-oauthazure-web-app-service

Microsoft Azure - Google OAuth2 redirect URI mismatch


I realize there are similar questions like this posted, but none I've read are applicable to my situation/resolved my issue.

I'm using Microsoft Azure and Visual Studio 2015 Pro. Google OAuth2 authenticates fine with a Google account using Visual Studio 2015 for localhost. However, when I publish to Microsoft Azure I receive the error "REDIRECT_URI_MISMATCH" after selecting the Google account I would like to use to authenticate.

I have the Google OAuth2 ID and Google OAuth2 Secret stored in the Authorization/Credentials Azure console under Google for authentication method. These credentials match the credentials I am using to test locally with Visual Studio 2015 which is successful for authentication.

What could possibly be causing this URI mismatch error even though I've checked over and over that the redirect URI referenced in the browser matches the redirect URI I've entered within the Google URI Redirect section of the console? Please see linked screenshots for the error and the URI information (placeholder/substitute site name used for privacy).

Note: I do know that within Visual Studio it asked me to add a firewall rule to allow my local IP for when I publish (I think to do with the Database). Irrelevant red herring? Just thought I'd mention it just in case.

  1. Google Error: redirect_uri_mismatch
  2. Google Console: Listed Redirect URIs

Solution

  • Credit truly goes to @WilliamDenniss

    Further Research: Using a proxy filter the actual request information showed Microsoft Azure was not utilizing the correct parameter (even though it was correct in the Microsoft Azure console) for client_id (as William Denniss suggested) and the browser (Google Chrome) was reporting the correct credentials in the error returned as well as (surprisingly) the correct information in the address bar. I suspect this was a glitch to do with sessions/cache - it's worth noting I am using the newer somewhat unfinished Azure Console that Microsoft is converting to.

    Solution: I not only had to create new credentials within Google Console for the project I had created and match these new credentials in Microsoft Azure console but also clear my entire cache/cookies etc. in order for the correct parameter for client_id to be sent/used, which I again verified using a proxy filter. Only after I did all of the above that I mentioned did the error resolve itself.