How to read auth0 claims in my .NET web api from an access token?

Hi there all!

I am creating an application where I want to retrieve auth0 user information within the web api. I am using Vue and .NET 6. I have an application set up for my Vue app, and an API created for my .NET application. Currently, I am able to view user data in my Vue application, login and access authorized data from my .NET web api, but I can’t grab the user information from the claims.

I have been reading articles about this topic, and many times I find .NET MVC articles, which I don’t believe fit my specific needs.

In this application, each user will have their own data stored and retrieved by some key. Currently, I want to store user related data by an email (or maybe some other field that is unique). The claims I am getting in my .NET web api don’t contain the actual user email.

Is there a way I can retrieve something like the user’s name and email in my web api? Should I even want to do this, or should I use the auth0 ID? In the future I would also like to be able to initialize a user with their auth0 information from the web api to supply user information in the database, but I suppose I could have a profile page to manage those values in the future.

To summarize, I would like to be able to retrieve and read auth0 claims in my web api from the access token retrieved. Are there any posts or repos I can use to reference on this issue?


Also for clarification, if I am supposed to use the auth0 user name claim as the unique key, is there a way I can prepopulate a new user’s information from the auth0 user? For instance, if someone logs into my app, creates a user account, I don’t want to force them to have to create a profile right after.

I would prefer to be able to prepopulate that information from auth0, and then allow them to change their information for my application (only relative to the application, I am not asking the applications to update auth0 information in any way).

Should I be using this pattern or is there another suggested way to go about this?