How can I access a user's openId/OAuth avatar and email address in MVC5?

Garrett Fogerlie

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

spaceman

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...

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I access Google+ user's email and pictures address through OWIN in ASP.NET 4.5 C#?

As an admin, can I modify a Firebase user's email address?

How can I programatically attach recovery email when creating user's e-mail address

How can you get an Android user's email address?

How can I retrieve the current user email address?

How do I change a user's Email address in MediaWiki

Avatar for an email address

How can I access this email attribute as self if it's a class attribute?

How do I record the email address of a user that clicks a link in an email?

How can I validate email address with jQuery?

How can I validate an email address in JavaScript?

Can I change root's email address or forward it to an external address?

How can I get the specific fields of the currently logged-in user in MVC5?

How can i check if user is logged in from the MVC5 Layout file

How can I link multiple email address to one user in Azure DevOps?

How can I store 2 same email address with different user UID in firebase Authentication

Microsoft Azure AD graph API: How do I retrieve a user's email address?

Changing user's email address

How do I get the Id of a user given the email address in ASP.NET MVC Entity Framework

How can I access another user's resources (specifically emails) using Microsoft Graph in an MVC app?

Email is not sent to user's email address in *.js

How can I set Thunderbird's "Recipient" column to display my email address rather than a friendly name?

How do I verify an email address to a certain user in ios swift?

How can a user's mailbox be configured to use a shared mailbox's email address as its primary in Office365?

How can I set the Firebase Firestore rules if I want the user can access even there's no current user

how do I verify a new user's email in Flutter and Firebase before granting them access to the app?

In Graph Facebook API, how can I get the user's id given users's email?

How can I manually check the url authorization in MVC5?

How can I extend the HttpCookie object in MVC5?