Link to home
Start Free TrialLog in
Avatar of barney1234
barney1234Flag for Australia

asked on

ASP.NET Core Web Client and AWS Cognito User pool to log in and authenticate web client only using AdminInitiateAuthAsync(request)

ASP.NET Core Web Client (RAZOR) Log In using AWS Cognito user pool and AWS .NET SDK to log in user in asp.net core web client

How to use AWS cognito user pool to authenticate and authorise ASP.NET Core WEb Client and ASP.NET Core Web API.

I already created a AWS Cognito User pool and App CLient.. I followed the below article from AWS

https://aws.amazon.com/blogs/mobile/use-csharp-to-register-and-authenticate-with-amazon-cognito-user-pools/

reached the point

      var cognito = new AmazonCognitoIdentityProviderClient(_region);
            //var cognito = new AmazonCognitoIdentityProviderClient(credentials);


            var request = new AdminInitiateAuthRequest
            {
                UserPoolId = _aWSConfig.PoolID,
                ClientId = _clientId,
                AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH
            };

            request.AuthParameters.Add("USERNAME", "test@test.com");
            request.AuthParameters.Add("PASSWORD", "P@ssword12");

            var response = await cognito.AdminInitiateAuthAsync(request);

            return strToken = response.AuthenticationResult.AccessToken;

1. what are the next steps so that asp.net core web client is aware the user is logged in ??

example the below are set

User.Identity.IsAuthenticated

User.Identity.Name


User.Claims

2. what other details from token need to be stored where and how in ASPNET Client so that these can be used to send in HTTPCLient request header to consume web api ?


3 When sending HTTPClient request to web API how to add the ID token in headed?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.