如何使用 DotNetOpenAuth 检索 google 个人资料?

发布于 2024-10-05 21:47:53 字数 560 浏览 0 评论 0原文

我正在尝试使用 DNOA 为我的应用程序提供 OpenId 支持,以便离开我迄今为止一直使用的 Janrain 解决方案。问题是,到目前为止,我拥有的用户拥有基于个人资料的标识符(https://www.google.com/profiles/11223344556677...),而 DNOA 检索到的标识符的形式为 https://www.google.com/accounts/o8/id?id=xxxxxyyyyyyafgsdgfsdhg

如何检索个人资料信息?通过属性交换?以及哪个属性?或者还有其他的API吗?我看到登录页面有一个 google 提供程序和一个不同的 google profile 提供程序,所以这里有人有答案...:)

更新: google profile 的端点是 (https:/ /www.google.com/profiles/)

所以...现在的问题是如何获取 google 个人资料 ID 号

I am trying to use DNOA for OpenId support to my app, in order to leave the Janrain solution I have been using so far. The problem is that the users I have so far have profile based identifiers (https://www.google.com/profiles/11223344556677... ), while the identifier retrieved by DNOA is in the form https://www.google.com/accounts/o8/id?id=xxxxxyyyyyafgsdgfsdhg.

How do I retrieve the profile information? Through Attribute Exchange? and which attribute? Or is there some other API? I saw that the login page has a provider for google and a different one for google profile, so someone around here has an answer... :)

Update: the endpoint for google profiles is (https://www.google.com/profiles/)

So... the question now is rather how to get the google profile id number

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-10-12 21:47:53

谷歌个人资料 ID 号是通过“http://schemas.openid.net/ax/api/user_id”属性检索的。将其设置为必需

在 DNOA 中,

var fetch = new FetchRequest();

fetch.Attributes.AddRequired("http://axschema.org/contact/country/home");
fetch.Attributes.AddRequired("http://axschema.org/contact/email");
fetch.Attributes.AddRequired("http://axschema.org/namePerson/first");
fetch.Attributes.AddRequired("http://axschema.org/namePerson/last");
fetch.Attributes.AddRequired("http://axschema.org/pref/language");
fetch.Attributes.AddRequired("http://schemas.openid.net/ax/api/user_id");

有趣的是,如果我省略其中一些属性,我将无法获取 api/user_id。
无法弄清楚那部分,但我现在并不关心。

the google profile id number is retrieved through the "http://schemas.openid.net/ax/api/user_id" attribute. Set this to required

In DNOA,

var fetch = new FetchRequest();

fetch.Attributes.AddRequired("http://axschema.org/contact/country/home");
fetch.Attributes.AddRequired("http://axschema.org/contact/email");
fetch.Attributes.AddRequired("http://axschema.org/namePerson/first");
fetch.Attributes.AddRequired("http://axschema.org/namePerson/last");
fetch.Attributes.AddRequired("http://axschema.org/pref/language");
fetch.Attributes.AddRequired("http://schemas.openid.net/ax/api/user_id");

funny thing is that, if I omit some of these attributes, I don't get the api/user_id back.
Can't figure that part out, but I don't really care at this point.

绅刃 2024-10-12 21:47:53

Google 实际上有 2 个(也许更多)openid 提供商 - 帐户和个人资料。我真的不知道为什么有 2 个,但所有 Google 帐户所有者都没有 Google 个人资料。

两者之间也有很大的区别。 Google 个人资料 openid 标识符在您使用的任何地方都是相同的。 Google 帐户 ID 不是!当作为 OpenID 提供商使用 Google 帐户登录时,您将为每个域获得不同的 ID。这是 OpenID 的一个新功能(我认为是可选的),但我现在不记得它的名字了。

尽管如此,我认为 Google 不会向您提供任何 Google 帐户标识符与 Google 个人资料标识符相关的数据。

希望这有任何帮助。

Google actually has 2 (maybe more) openid providers - accounts and profiles. I don't really know why there are 2 but all Google Account owners do not have a Google Profile.

There is also a big difference between the two. Google Profiles openid identifier is the same anywhere you use it. Google Accounts id is not! When logging-in with Google Accounts as an OpenID provider you'll get different ID for every domain. It's a new (optional, I think) feature of OpenID, but I can't remember it's name at this moment.

With all that said I don't think Google will give you any data which Google Account identifier correlates to which Google Profiles identifier.

Hope this helps in any way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文