Create and Verify a New User on a Cognito User Pool

George Stefanis
George Stefanis

If you just created a new Cognito User Pool and you want to add a new user fear not. You can add that user using the cognito interface but you won't be able to do much with it as the user will need to be verified and change their password.

Register a new user

You can go to the user interface of your Cognito User Pool and add the user there. That's my preferred way at this stage. If you don't want that there is a CLI command for this:

aws cognito-idp sign-up --region {your-aws-region} --client-id {your-client-id} --username admin@example.com --password password123

Confirm user registration

Now that your user is there you will need to confirm the registration and remove that annoying "user needs to change password".

aws cognito-idp admin-set-user-password
  --user-pool-id <your-user-pool-id> \
  --username <username> \
  --password <password> \
  --permanent

Authenticate the user and take tokens

Now you can finally authenticate with that user and get some tokens that you can use for calling APIs or whatever else.

aws cognito-idp admin-initiate-auth 
  --user-pool-id <your-user-pool-id> 
  --client-id <YOUR_CLIENT_ID> 
  --auth-flow ADMIN_NO_SRP_AUTH 
  --auth-parameters USERNAME=YourUserName,PASSWORD="hunter12"