As noted, the access_token
does not contain any information about the user other than the user’s ID. In order to get more information about the user, you will have to call the /userinfo
endpoint, passing along the access_token
For more information, please read the following blog post:
You can find documentation on the /userinfo
endpoint at:
https://auth0.com/docs/api/authentication#get-user-info
You can use the Auth0.NET SDK to call this endpoint. Documentation is available at:
Documentation
First install the NuGet package:
Install-Package Auth0.AuthenticationApi
Then, the code you will have to write is something like the following:
using Auth0.AuthenticationApi;
var client = new AuthenticationApiClient("XXXX.eu.auth0.com"));
var userInfo = await client.GetUserInfoAsync("your access_token");
HOWEVER, since you have to make an extra call to the Auth0 Authentication API each time to retrieve the user’s email address, I would highly recommend rethinking your DB structure, and instead identify the user in your database with their user ID, and not their email address