ASP.NET (OWIN): User Profile
This tutorial demonstrates how to get the user's profile and display it. We recommend you to Log in to follow this quickstart with examples configured for your account.
I want to integrate with my app15 minutes
I want to explore a sample app2 minutes
Get a sample configured with your account settings or check it out on Github.
1. Establish two Auth0 Tenants
Getting the profile
The OpenID Connect middleware will automatically retrieve the user's information from Auth0 and add it as claims to the
ClaimsIdentity. The seed project contains a controller action and view which will display the claims associated with a particular user. Once a user has signed in, you can go to
/Account/Claims to see these claims.
By default, the
Update the OpenID Connect middleware configuration and set the value of the
Scope property to
openid profile email:
You may also want to create a user profile page which will display a user's name, email address and profile image.
First, create a view model which will contain the basic user profile information, such as a
Add a new
Profile action to the
AccountController and extract the relevant claims and add them to a new instance of
UserProfileViewModel which is then passed to the view. Be sure to decorate the action with the
[Authorize] attribute so only authenticated users can access the action:
Next, create a view. For the view, display a user profile card at the top with the user's name, email address and profile image.
Now when you log in and then go to the URL
/Account/UserProfile you will see the user's profile displayed.
In the Auth0 Dashboard
You may also want to put a link in the top navigation bar to display the user's name, and when the user clicks on that, you can navigate them to their Profile page.
Go to the
Views/Shared/_Layout.cshtml file and update the Navbar section which displays the Login and Logout options to also display the user's name and link to the
Profile action in the
Now, after the user has logged in you will be able to see their name in the top right corner of the navigation bar: