如何使用DotNetOpenAuth检索Google个人资料? [英] How do I retrieve google profile with DotNetOpenAuth?

查看:86
本文介绍了如何使用DotNetOpenAuth检索Google个人资料?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

如何检索个人资料信息?通过属性交换?以及哪个属性?还是有其他一些API?我看到登录页面上有一个Google提供程序,另一个是Google个人资料提供程序,所以这里的某人有一个答案...:)



更新: google个人资料的终结点是(https://www.google.com/profiles/)



所以...现在的问题是以获得Google个人资料ID号

解决方案

通过 http://schemas.openid检索Google个人资料ID号。 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返回。
无法弄清楚那部分,但是我现在并不在意。


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

解决方案

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.

这篇关于如何使用DotNetOpenAuth检索Google个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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