Question

I want my website to automatically add the user's email address and avatar when they register via OpenId or OAuth. MVC 5 allows a user to register and login with their openId Google, Facebook, or Twitter account, however it doesn't seem to pass any of the linked information back to the website.

I already have a user profile model that gets created when the user registers, but I would like to be able to add their Email address and avitar without having to ask them for it. How can I access the user's linked avatar and email address that is associated with their Google/Facebook/Twitter account once they register through an openId?

So far the information I have found and tried seems to be applicable to MVC 4 or the release candidate of MVC 5 and doesn't seem to work.

Thanks

Was it helpful?

Solution

I asked the exact same question over here :

How do i retrieve the email address when using google auth in mvc 5?

credit goes to jd4u for the answer

You can retrieve it from ClaimIdentity as an Email Claim

Check this example

var email = externalIdentity.FindFirstValue(ClaimTypes.Email);

Regarding the profile pic, once again jd4u pointed me to :

Get ExtraData from MVC5 framework OAuth/OWin identity provider with external auth provider

I ended up using their gravatar image instead, as it seemed less work. And thats what gravatar is for anyway...

OTHER TIPS

Look into Gravatar it's pretty easy to implement and you may retrieve more images.

From their site....

An "avatar" is an image that represents you online—a little picture that appears next to your name when you interact with websites. A Gravatar is a Globally Recognized Avatar. You upload it and create your profile just once, and then when you participate in any Gravatar-enabled site, your Gravatar image will automatically follow you there. Gravatar is a free service for site owners, developers, and users. It is automatically included in every WordPress.com account and is run and supported by Automattic.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top