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?

질문됨 일 년 전518회 조회
1개 답변
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

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인