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?

posta un anno fa520 visualizzazioni
1 Risposta
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

con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande