How do I retrieve google profile with DotNetOpenAuth?

主宰稳场 提交于 2019-11-30 19:31:51

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4365572/how-do-i-retrieve-google-profile-with-dotnetopenauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!