identity 2.1 google authentication

Feb 17, 2015 at 12:51 PM
I'm using trying to use Google authentication in an ASP.NET MVC application.
For testing purposes I'm using the template app generated by VS2013 Update 4

In Google settings the return URLs are properly set and Google+ API is turned on

It works fine when I publish the app to an azure website. I can login using Google accounts without any problems.

However I'd like to deploy it on premises but here we have a reverse proxy setup which works like this:
  • the server sees itself as but this is an internal name
  • outside world sees it as (certain paths are reverese proxied to the
Essentially is reverse proxied to

With this setup I can't seem to use Google authentication. GetExternalLoginInfoAsync returns null and the app redirects itself to the login page.

By default the system generates a redirectUri using the private hostname. I tried changing it to the public address but this does not solve the problem.
Below is what I did at startup.auth.cs
            app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
                ClientId = "...",
                ClientSecret = "...",

                Provider = new GoogleOAuth2AuthenticationProvider
                    OnApplyRedirect = context =>
                        var redirectUri = context.RedirectUri.Replace("server01", "www");

Is there anyway I can make Google authentication work in a setup like this?