# Logged In User Information

**URL:** <https://community.auth0.com/t/logged-in-user-information/103787>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [March 30, 2023, 8:41pm UTC](https://community.auth0.com/t/logged-in-user-information/103787 "2023-03-30T20:41:21Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [March 30, 2023, 8:41pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/1 "2023-03-30T20:41:21Z")

</div>

I’m really confused on how to get additional information about a user once they log in. I have a sample Blazor server app and am able to login but the only thing I can see is the users name (user.Identity.Name). I’ve looked at all of the documentation and samples and just keep going in circles on how to basic stuff.

When I try to access the email address for the logged in user, it is blank. Do I have to add that field to the claims in the dashboard or a scope somewhere?

```auto
protected override async Task OnInitializedAsync()
{
    var state = await AuthState.GetAuthenticationStateAsync();

    Username = state.User.Identity.Name ?? string.Empty;
    NickName = state.User.Claims
        .Where(c => c.Type.Equals("nickname"))
        .Select(c => c.Value)
        .FirstOrDefault() ?? string.Empty;

    await base.OnInitializedAsync();
}

```

On the state.User.Claims object, I was able to only see the following properties: name, nickname, picture, updated\_at, “[http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier](http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier)”, and sid.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 30, 2023, 11:12pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/3 "2023-03-30T23:12:23Z")

</div>

Hey there @MountainTopTech welcome to the community!

Thanks for the detailed description of the issue - While I’m not super familiar with our [ASP.NET](http://ASP.NET) CORE [SDK](https://github.com/auth0/auth0-aspnetcore-authentication#api-reference), you will need to include the `email` scope when configuring the it. I believe this may be what you are looking for:

[https://auth0.github.io/auth0-aspnetcore-authentication/api/Auth0.AspNetCore.Authentication.Auth0WebAppWithAccessTokenOptions.html#Auth0\_AspNetCore\_Authentication\_Auth0WebAppWithAccessTokenOptions\_Scope](https://auth0.github.io/auth0-aspnetcore-authentication/api/Auth0.AspNetCore.Authentication.Auth0WebAppWithAccessTokenOptions.html#Auth0_AspNetCore_Authentication_Auth0WebAppWithAccessTokenOptions_Scope)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [March 31, 2023, 12:15am UTC](https://community.auth0.com/t/logged-in-user-information/103787/4 "2023-03-31T00:15:16Z")

</div>

Hi @MountainTopTech  
As well as what my colleague @ty.frith said, I think the Blazor implementation will query the /userinfo endpoint to populate the Id Token with the standard claims. If you need the other claims associated with the user profile you may need to create an [Action](https://auth0.com/docs/customize/actions) to copy those into the Id Token. Something like the below should do the trick depending on what you need from the user profile:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://my-app.example.com';
  api.idToken.setCustomClaim(`${namespace}/email`, event.user.email);
  api.idToken.setCustomClaim(`${namespace}/user_metadata`, event.user.user_metadata);
};

```

I tried this out on my Blazor app and got the below when enumerating through my claims:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/2/62bc2b8ccf39ee7b1e420df2ed881f88db9186eb.png)

Hope this helps.  
Warm regards.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [March 31, 2023, 1:41pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/5 "2023-03-31T13:41:17Z")

</div>

Not sure how that helps me.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [March 31, 2023, 2:22pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/7 "2023-03-31T14:22:15Z")

</div>

I’ve added the custom action but not sure what to use for the namespace? Do I need that?

I tried looking for the email claim that is in the action but nothing shows up.

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [March 31, 2023, 3:49pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/8 "2023-03-31T15:49:58Z")

</div>

Hi @MountainTopTech

Best practice is to use namespaced claims to avoid any sort of name collision. The namespace could be your own domain for example. If you have good reason you can now leave off the namespace but follow these guidelines [https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#non-namespaced-guidelines](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#non-namespaced-guidelines)

So you’ve created a [Post Login Action](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow) and are adding email from the user profile to the Id Token but you cannot find it in your application when logging in?

Try putting some console.logs in your Action to ensure it’s executing and inspecting variables and use the [Real-time webtask logs extension](https://auth0.com/docs/customize/extensions/real-time-webtask-logs) to view the output of those logs.

If you’re happy it’s executing try looping through the claims in your app post login to check it is there.

Warm regards.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [March 31, 2023, 5:12pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/9 "2023-03-31T17:12:35Z")

</div>

I feel like I may be close. This is my post login action which I deployed:

```auto
exports.onExecutePostLogin = async (event, api) => {
  api.idToken.setCustomClaim(`email`, event.user.email);
};

```

Then I realized that I did not add it to the Flow so I have added to the flow and applied as follows:  
 ![2023-03-31_11-09-05](https://global.discourse-cdn.com/auth0/original/3X/0/d/0db39e3db68a142bf4431eebc072907d755afe5f.png)

When I try to get the claim in the app, I do the following but is still empty:

```auto
Email = state.User.Claims
  .Where(c => c.Type.Equals("email"))
  .Select(c => c.Value)
  .FirstOrDefault() ?? string.Empty;

```

I tried adding the logging extension and running it but nothing appears in the log. When I test the action, the log appears with the email value. What triggers the Post-Login action? Maybe I need to set that up somewhere or does that happen automatically?

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [March 31, 2023, 9:58pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/10 "2023-03-31T21:58:58Z")

</div>

Hi @MountainTopTech

Sounds like you’re making great progress. Forgetting to add the Action to the flow…I’ve been there more than once 😅

I’m assuming you have a console.log at the top of the Action so you can see that it executes. I’m also assuming you’ve added your Action to the login flow as are a few flows available. If so then we should be seeing that console.log appear in the logs extension when you login via Universal Login. This is how we can prove that your Action does execute. Just ensure you hit the Apply button when you added your Action to the login flow as that has got me a couple of times too.

Once we know for sure that the Action does execute whenever you login to your application via Universal Login then your claim should come across into `state.User.Claims`.

Warm regards.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [April 1, 2023, 2:46am UTC](https://community.auth0.com/t/logged-in-user-information/103787/11 "2023-04-01T02:46:27Z")

</div>

I have the following code in my action:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://mynamespace.com';
  console.log('email: ' + event.user.email);
  api.idToken.setCustomClaim(`${namespace}/email`, event.user.email);
};

```

I have applied the flow and everything looks deployed.

The only thing I don’t understand is I am never calling the authorize endpoint from my Blazor Server app unless it is handled under the covers. In my index.razor page, I have the following code:

```auto
@code {
   private string Username = "Anonymous User";
   private string UserId = "";
   private string Email = "";

   protected override async Task OnInitializedAsync()
   {
       var state = await AuthState.GetAuthenticationStateAsync();

       Username = state.User.Identity.Name ?? string.Empty;
       UserId = state.User.Claims
           .Where(c => c.Type.Equals(@"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"))
           .Select(c => c.Value)
           .FirstOrDefault() ?? string.Empty;
       
       // Remove Auth0 prefix
       UserId = UserId.Split('|')[1];

       Email = state.User.Claims
           .Where(c => c.Type.Equals(@"https://mynamespace.com/email"))
           .Select(c => c.Value)
           .FirstOrDefault() ?? string.Empty;
       await base.OnInitializedAsync();
   }
}

```

What I don’t understand is how it knows to execute the Login flow for the application because right now, the email claim is not getting to the application. What am I missing?

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [April 6, 2023, 12:25am UTC](https://community.auth0.com/t/logged-in-user-information/103787/12 "2023-04-06T00:25:23Z")

</div>

Hi @MountainTopTech

Apologies for the delay in getting back to you on this.

My first question is did you confirm via the real-time webtask logs extension that the Action was indeed being executed i.e. the email was being sent to the logs as per your console.log?

On the Blazer app, the login is mostly under the hood (there could potentially be other implementations you could use giving you some control) but when you login you may get an Id Token, fire up the browser dev tools and then execute the login flow, you should see the /authorize, when you login you may also see a token:

![image](https://global.discourse-cdn.com/auth0/original/3X/f/1/f12ca575642390e7d1a9f481ff99f20e957dda12.png)

which contains an Id Token:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/e/b/eb4d68885b3686c72369cb7ef485ecf9710e79e9.png)

If you inspect the token in [https://jwt.io/](https://jwt.io/) you should see the custom claims there.

Warm regards.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [April 6, 2023, 6:35pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/13 "2023-04-06T18:35:40Z")

</div>

I can never get the real-time webtask logs to show anything. I read somewhere they only work with Rules and not Actions. Is that true? I don’t know if you can look at my setup and see if anything is wrong. I don’t know what else to try.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 6, 2023, 9:36pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/14 "2023-04-06T21:36:51Z")

</div>

Hmm you _should_ be able to see a `console.log` in the real-time webtask extension, however I’m currently not able to see any logging either. Another option is to inspect the “Successful Login” event in your dashboard at Monitoring → Logs. Any logging you add to your action will be printed here:

 ![Screenshot 2023-04-06 at 2.36.08 PM](https://global.discourse-cdn.com/auth0/original/3X/0/9/09a7ac91435060e5b7c7bcfbc7dfbca217dba654.jpeg)

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [April 7, 2023, 2:08am UTC](https://community.auth0.com/t/logged-in-user-information/103787/15 "2023-04-07T02:08:16Z")

</div>

The only logs I have are API Read Operation and nothing else. The filter is set to All with All Dates.

---

<div class="post-metadata">

**Author:** ![MountainTopTech](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@MountainTopTech](https://community.auth0.com/u/MountainTopTech)\
**Post date:** [April 16, 2023, 11:04pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/16 "2023-04-16T23:04:27Z")

</div>

Just a quick update.

I guess I needed to wait some time after deploying (how long I don’t know since it’s been 10 days since I am revisiting this) but now the logging shows the email claim logging and coming back to the client.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 17, 2023, 2:48pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/17 "2023-04-17T14:48:57Z")

</div>

Interesting, that’s good news though! Thanks for following up here 🙂

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 1, 2023, 2:49pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/18 "2023-05-01T14:49:42Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [May 14, 2024, 2:01pm UTC](https://community.auth0.com/t/logged-in-user-information/103787/19 "2024-05-14T14:01:31Z")

</div>

Hey team!

This topic seems related to our new EA feature, Forms for Actions, which rolled out of the beta stage on May 7th. Our Product team prepared the whole Documentation page with examples of Use cases. [Forms for Actions](https://auth0.com/docs/customize/forms). If you find yourself having questions regarding this new feature for the next two weeks, we are hosting an [Ask Me Anything session](https://community.auth0.com/t/auth0-community-ask-me-anything-customize-and-extend-ciam-with-new-forms-for-actions/133516). Our Product Expert will provide comprehensive written answers on May 21st from 8 AM to 10 AM PST.  
Find out more about [Forms for Actions](https://auth0.com/docs/customize/forms) and [learn more about AMA](https://community.auth0.com/t/auth0-community-ask-me-anything-customize-and-extend-ciam-with-new-forms-for-actions/133516).

Thanks!  
Dawid
