Using AWS Cognito, I want to create dummy users for testing purposes.
I then use the AWS Console to create such user, but the user has its status set to FORCE_CHANGE_PASSWORD
. With that value, this user cannot be authenticated.
Is there a way to change this status?
UPDATE Same behavior when creating user from CLI
Basically this is the same answer but for .Net C# SDK:
The following will make a full admin user creation with desired username and password. Having the following User model:
You can create a user and make it ready to use using:
not sure if you are still fighting with this but for creating a bunch of test users only, I used the
awscli
as such:Sorry you are having difficulties. We do not have a one step process where you can just create users and authenticate them directly. We might change this in the future such as to allow administrators to set passwords that are directly usable by users. For now, when you create users either using
AdminCreateUser
or by signing up users with the app, extra steps are required, either forcing users to change the password upon login or having users verify the email or phone number to change the status of the user toCONFIRMED
.For Java SDK, assuming your Cognito client is setup and you have your user in the FORCE_CHANGE_PASSWORD state you can do the following to get your user CONFIRMED... and then auth'd as normal.
Hope it helps with those integration tests (Sorry about the formatting)
You can change that user status FORCE_CHANGE_PASSWORD by calling respondToAuthChallenge() on the user like this:
After this, you'll see in the console that user3 status is CONFIRMED
OK. I finally have code where an administrator can create a new user. The process goes like this:
Step 1 is the hard part. Here's my code for creating a user in Node JS:
Basically, you need to send a second command to force the email to be considered verified. The user still needs to go to their email to get the temporary password (which also verifies the email). But without that second call that sets the email to verified, you won't get the right call back to reset their password.