How do I retrieve google profile with DotNetOpenAuth?

后端 未结 2 1237
北恋
北恋 2021-01-07 02:07

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 profi

相关标签:
2条回答
  • 2021-01-07 02:36

    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.

    0 讨论(0)
  • 2021-01-07 02:47

    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.

    0 讨论(0)
提交回复
热议问题