I'm registering users in AWS Cognito with C# based on the code provided in the following thread:
User management in AWS Cognito User Pool using C# and .NET
The way I'm registering a user is as follows:
CognitoUserManagement cognitoUserManagement = new CognitoUserManagement("default", RegionEndpoint.USEast1);
List<AttributeType> listAttribute = new List<AttributeType>();
await cognitoUserManagement.AdminCreateUserAsync(tbUserName.Text, pbPasswordUser.Password, _poolId, _clientId, listAttribute);
Works great until adminRespondToAuthChallengeRequest:
AdminRespondToAuthChallengeRequest adminRespondToAuthChallengeRequest = new
AdminRespondToAuthChallengeRequest
{
ChallengeName = ChallengeNameType.PASSWORD_VERIFIER,
ClientId = appClientId,
UserPoolId = userPoolId,
ChallengeResponses = new Dictionary<string, string>
{
{ "USERNAME", username },
{ "NEW_PASSWORD", password },
{ "TIMESTAMP", DateTime.UtcNow.ToString("o") }
},
Session = adminInitiateAuthResponse.Session
};
In this part of the code, an exception is thrown stating that PASSWORD_CLAIM_SIGNATURE is required
I have been looking for what it can be about or what I should do but, I can not solve the problem.
Any comment or suggestion is welcome.
UPGRADE
It seems that it is the secret key or App client secret:
CognitoHashCalculator cognitoHashCal = new CognitoHashCalculator();
string cognitoHashCal = cognitoHashCal.GetSecretHash(username, appClientId, "YourAppSecretKey");
...
ChallengeResponses = new Dictionary<string, string>
{
{ "USERNAME", username },
{ "NEW_PASSWORD", password },
{ "TIMESTAMP", DateTime.UtcNow.ToString("o") },
{ "PASSWORD_CLAIM_SIGNATURE",pass}
},
This way you get to the last part of the code:
AdminRespondToAuthChallengeResponse adminRespondToAuthChallengeResponse = adminAmazonCognitoIdentityProviderClient
.AdminRespondToAuthChallengeAsync(adminRespondToAuthChallengeRequest)
.Result;
Here a new exception happens:
InvalidParameterException: Missing required parameter PASSWORD_CLAIM_SECRET_BLOCK