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?

feita há um ano518 visualizações
1 Resposta
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

respondido há um ano

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas