从OpenID的Asp.net身份谷歌帐户ID迁移到OAuth [英] Asp.net identity Google account id migration from openId to oauth

查看:115
本文介绍了从OpenID的Asp.net身份谷歌帐户ID迁移到OAuth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用DotNetOpenAuth对谷歌OpenID身份验证现有的asp.net应用mvc5。
我迁移到Asp.Net身份,并使用Google+的验证与OAuth2.0的。

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

不过,我已经看到吴丹我不能映射现有的OpenID帐户的ID以OAuth2.0的标识:
   - 老ID为: https://www.google.com/accounts/o8/ ID?ID = blablabla
   - 新的ID为:长号

But I have seen thant I can't map existing OpenId account Id to OAuth2.0 Id : - Old id is : https://www.google.com/accounts/o8/id?id=blablabla - New Id is : a long number

因为我想用新的ID,我正在寻找有关迁移身份帮助。
我还没有发现没有一个简单的示例来实现这一点。

Since I would like to use new id, I am searching for help on migrating identities. I have not found yet a simple sample to achieve this.

我使用的是新的asp.net应用mvc5(新鲜脚手架),加入Microsoft身份(与我的数据自定义实现),配置了GoogleOAuth2提供商。

I am using a new asp.net mvc5 application (freshly scaffolded), added Microsoft Identity (with custom implementation for my data), configured the GoogleOAuth2 provider.

当我尝试登录,惊喜! :)帐户ID已经改变...

When I try to login, surprise ! :) Account id have changed...

我看过一些帖子,告诉添加openid.realm要权威性的要求,但,我怎么能更改身份验证请求的URL,而且我怎么知道把它的价值呢?

I have read some posts that tell to add "openid.realm" to auth request but, how can I change the authentication request url, and how do I know the value to put in it ?

感谢。

推荐答案

要更改身份验证请求,包括 openid.real m参数,您可以使用OnApplyRedirect委托例如:

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

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);
        },
    }
});

的值 openid.realm 需要是的境界时使用的OpenID的2.0

The value of openid.realm needs to be the realm you used for OpenID 2.0

借助谷歌迁移DOC 对如何从地图信息老用户ID给新

The google migration doc has information on how to map from the users old id to the new one

这篇关于从OpenID的Asp.net身份谷歌帐户ID迁移到OAuth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆