Asp.net account id id from openId to oauth

I have an existing asp.net mvc5 application using DotNetOpenAuth to authenticate Google OpenId. I am switching to Identity Asp.Net and using Google+ Auth with OAuth2.0.

But I saw that I can not match the existing OpenId account ID with OAuth2.0 Id: - Old identifier: https://www.google.com/accounts/o8/id?id=blablabla - New identifier: long number

Since I would like to use a new identifier, I am looking for help in transferring identifiers. I have not yet found a simple example for this.

I am using the new asp.net mvc5 application (recently created), added by Microsoft Identity (with a custom implementation for my data), set up the GoogleOAuth2 provider.

When I try to log in, be surprised! :) The account ID has changed ...

I read a few posts that say to add "openid.realm" to the auth request, but how can I change the URL of the authentication request and how do I know its value?

Thank.

+2
source share
1 answer

To change the authentication request to include the openid.realm parameter , you can use the OnApplyRedirect delegate, for example.

app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
    ClientId = "",
    ClientSecret = "",
    Provider = new GoogleOAuth2AuthenticationProvider
    {
        OnApplyRedirect = context =>
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>()
            {
                { "openid.realm", "http://mywebsite.com/openid/realm" }
            };
            var redirectUri = WebUtilities.AddQueryString(context.RedirectUri, dictionary);
            context.Response.Redirect(redirectUri);
        },
    }
});

The value openid.realmmust be the realm that you used for OpenID 2.0

google migration doc , .

+2

All Articles