How to use DotNetOpenAuth to log into Google, and get user profile
I just want to login with google and want access logged in user's general profile like photo, email address and name, to display开发者_运维问答 on my site. Is it possible with DotNetOpenAuth?
That's trivially easy. Use OpenID to "just login", instead of OAuth. Take a look at the OpenIdRelyingPartyWebForms or OpenIdRelyingPartyMvc samples for how to log a user in. Since you're only interested in logging the user in with Google, rather than displaying an input box you can just have a "Login with Google" button that calls OpenIdRelyingParty.CreateRequest("https://www.google.com/accounts/o8/id")
to initiate a Google login.
As @Lirik pointed out in a comment, you can use AX to retrieve user profile info. However I don't think that will get you the user photo. If Google even makes that available (big if) you may have to use OAuth for that. And I would recommend in that case that you use the "OpenID+OAuth" extension for that, which I believe leads you to the "Google Contacts" sample you have already seen. To change that to retrieve a user photo however, you'd need to review Google's own GData API documentation to see how to retrieve a user photo (if you can).
精彩评论