AWS Cognito - .NET Framework

0

I'm trying to connect to AWS Cognito from a .net Framework project.

I can sign up succesfully but when I need to sign in, throws me an error: "User pool {userPool} client does not exist".

This is my code:

private async Task<bool> CheckPasswordAsync(string userName, string password)
        {
            try
            {

                
                var authReq = new AdminInitiateAuthRequest
                {
                    UserPoolId = ConfigurationManager.AppSettings["USERPOOL_ID"],
                    ClientId = ConfigurationManager.AppSettings["CLIENT_ID"],
                    AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH,
                    
                };
                authReq.AuthParameters.Add("USERNAME", userName);
                authReq.AuthParameters.Add("PASSWORD", password);
                

                AdminInitiateAuthResponse authResp = await _client.AdminInitiateAuthAsync(authReq);


                var auts = authResp;
                return true;
            }
            catch(Exception ex)
            {
                var exc = ex.Message;
                return false;
            }
        }

I don't know if I need to add more information to the method.

The user pool exists and is the same that I have in appSettings.

Any idea about what's wrong?

Thanks in advance.

gefragt vor 2 Jahren694 Aufrufe
1 Antwort
0

Hello,

Thank you for your question.

Your code is missing some prerequisite steps needed to register the user pool. I have attached a document that shows the step by step on how to register and authenticate with Cognito user pools. I have also included a document that contains code examples.

Documentation:

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

https://docs.aws.amazon.com/code-library/latest/ug/cognito-identity-provider_code_examples.html

beantwortet vor 2 Jahren
profile picture
EXPERTE
überprüft vor 14 Tagen

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