AWS Cognito with Blazor ( userName is not showing)

0

Hi AWS Team, I am integrating the AWS Cognito Service in Blazor Server 6.0. I have created the AWS cognito configuration like this post

https://chandradev819.com/2020/01/18/aws-cognito-service-in-asp-net-core-3-1-application/

All configuration is fine, after login, I am not seeing the UserName

Enter image description here

I am reading the UserName like this

<AuthorizeView>
    <Authorized>
        <a>Hello, @context.User.Identity.Name </a>
        <form method="get" action="logout">
            <button type="submit" class="nav-link btn btn-link">
                Log
                out
            </button>
        </form>
    </Authorized>
    <NotAuthorized>
        <a href="login?redirectUri=/">Log in</a>
    </NotAuthorized>
</AuthorizeView>

could you please let me know, is it possible to use cognito in Blazor or not? If yes, please share some document or post on this?

asked a year ago505 views
1 Answer
0

Hey,

I am not sure that gets populated but you could check this:

_httpContextAccessor.HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName)?.Value;

This example will get you the first name but you should be able to see all the claims in that User.Claims collection

Thanks

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions