Auth0 Home Blog Docs

Unable to obtain email address from authenticated user

.net
userinfo
email

#1

Below is the code that I am using to get the email address of the logged in user

string email = ClaimsPrincipal.Current.FindFirst("email")?.Value;

Now I also added email to the scope, but still its not bringing the user email id

auth.authorize({
          audience: 'https://'+AUTH0_DOMAIN+'/userinfo', // you can also set this on the .env file and put API_AUDIENCE instead
          scope: 'openid email profile',
          responseType: 'code',
          redirectUri: AUTH0_CALLBACK_URL
        });

#2

In future you should be more specific about technologies as otherwise it’s harder and slower to provide definitive responses. Based on the code I can assume .NET and if I recall correctly ClaimsPrincipal.Current is not recommended/usable in .NET Core so you have some other variation of a .NET application.

With the above in mind and given that you’re already including the email scope the most likely issue is that the .NET JWT validator performs claims translation for the most common ones so the email claim coming from the ID token is getting mapped to another one. I did my tests with .NET Core and although you’re likely not using that the claim mapping is something common so if you do the following:

.FindFirst(System.Security.Claims.ClaimTypes.Email)?.Value;

instead of

.FindFirst("email")?.Value;

it may address the situation. If not you should really be much more specific about your scenario and include relevant code snippets and steps to reproduce.


#3

First, there is no “MAIL TO”. The commands are “MAIL FROM:” and “RCPT TO:”. MAIL FROM is the address of the sender and is generally not checked. It’s used only if there is an error in delivery. RCPT TO is the receiver’s address Webgen.


#4

When you connect to a mail server without authenticating or logging in, you can only send mail to a person hosted on that server Webgen.


#5