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?

gefragt vor einem Jahr518 Aufrufe
1 Antwort
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

beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen