Microsoft.AspNet.Identity and Google SSO in OWIN

Dec 9, 2013 at 9:44 PM
I'm trying to use Google SSO provided in OWIN with VS2013's SPA template, however it is giving me null pointer exception in RegisterExternalLogin.aspx.cs on the following line, no matter which gmail account I tried to use to sign in.
            var loginInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo();
I debugged and checked the source code of GoogleAuthenticationHandler and noticed that a claims is correctly received (though I'm not sure if all the required claims to be used by GetExternalLoginInfo is there).

I've also noticed that the code is requesting some attribute that doesn't seem to exist in google's document?
                    "&" + Uri.EscapeDataString("") +
                    "&" + Uri.EscapeDataString("") +
                    "&" + Uri.EscapeDataString("") + (optional) Requests the user's home country. This value must be set to "". (optional) Requests the user's gmail address. This value must be set to either "" or "". (optional) Requests the user's first name. This value must be set to "". (optional) Requests the user's preferred language. This value must be set to "". (optional) Requests the user's last name. This value must be set to "".
Dec 12, 2013 at 3:12 PM
Thoughts anyone? Not sure I'm doing anything different, I simply un-comment the app.UseGoogleAuthentication() line.
Dec 12, 2013 at 5:38 PM
Dec 16, 2013 at 4:45 PM
Hi Tractcher,

I see that it is indeed the case, however the related issue was closed as fixed. Should I open a new one for google? This seems like a general implementation requirements for all OWIN middleware to ensure that the returned Identity needs to have ClaimsIdentity.Name filled with a none null string?
Dec 16, 2013 at 5:44 PM
Facebook got fixed because we had a repro.

Sure, open a new bug for Google. Do you know which key is missing and which one should be the fallback? Any hints on how the google account was configured would also help us repro this.
Dec 16, 2013 at 7:40 PM
Is there any reason why the default name cannot always fallback to email, then ClaimTypes.NameIdentifier? Those values seems to be more consistently available than first/last name?

Also, there are two reason why first/last name are not available
  1. when building authorizationEndpoint, the code requests name, first, last,
                    "&" + Uri.EscapeDataString("") +
                    "&" + Uri.EscapeDataString("") +
                    "&" + Uri.EscapeDataString("") +
                    "&" + Uri.EscapeDataString("email,name,first,last");
However, according to
There's no and, should be,

The required string should be email,firstname,lastname instead.
  1. I noticed that the google account I had problem logging in with OWIN is showing
Your profile was suspended because it violates our names policy

in its google+, perhaps that is the reason why google returns no first/last name for the account? However, it has never stopped me from using the account to sign into any other services. I don't think it is a big deal that user doesn't have a first/last name as long as they have a proper NameIdentifier?