sst.dev icon indicating copy to clipboard operation
sst.dev copied to clipboard

Comments: Create a Cognito Test User

Open jayair opened this issue 9 years ago • 55 comments

Link to chapter - http://serverless-stack.com/chapters/create-a-cognito-test-user.html

jayair avatar Apr 10 '17 00:04 jayair

to create the user and confirm I had to add an extra parameter to both calls (--region us-east-1)

$ aws cognito-idp sign-up \
  --client-id YOUR_COGNITO_APP_CLIENT_ID \
  --username [email protected] \
  --password Passw0rd! \
  --user-attributes Name=email,[email protected] \
  _**--region us-east-1**_

Pancakerobot avatar Apr 10 '17 04:04 Pancakerobot

@Pancakerobot good tip, we've gotten some feedback from some people that have run into region related issues.

jayair avatar Apr 10 '17 17:04 jayair

I had the same problem. You get the region from your Pool Id. Mine was us-east-2_dUMVe5SZr but it doesn't look like you need anything after the underscore. so tacking on --region us-east-2 worked for me

geirman avatar Apr 14 '17 22:04 geirman

Added it to the chapter - 562b54b252423011d418e16aed20083d403c4b18

jayair avatar Apr 14 '17 22:04 jayair

I'm having trouble running

$ aws cognito-idp sign-up
--region us-east-1
--client-id YOUR_COGNITO_APP_CLIENT_ID
--username [email protected]
--password Passw0rd!
--user-attributes Name=email,[email protected]

Actually when I even try running the first line "aws cognito-idp sign-up" into the command prompt (im using windows), it just gives me this error.

cmd trouble

I'm pretty sure I configured it in the beginning. Any help would be greatly appreciated.

`

zohaibshahzadTO avatar May 15 '17 02:05 zohaibshahzadTO

@Hollow27 When you try the full command (with the client-id passed in), what is the error you are seeing?

jayair avatar May 15 '17 17:05 jayair

This is what I'm getting (kind of a noob using the terminal): cmd555

Unknown output type: [None]

^thats what im getting when I try the full command with client-id passed in.

zohaibshahzadTO avatar May 16 '17 23:05 zohaibshahzadTO

@Hollow27 Yeah I'm not too familiar with Windows. But @ryanjcruz is a Windows user. Maybe he can help you?

jayair avatar May 17 '17 16:05 jayair

@jayair @Hollow27 you'd need to add \ at the end of the command per line i.e $ aws cognito-idp sign-up \ --region us-east-1 \ --client-id YOUR_COGNITO_APP_CLIENT_ID \ --username [email protected] \ --password Passw0rd! \ --user-attributes Name=email,[email protected]

then the last line shouldn't have any as that should be the enter key needed to execute the command.

ryanjcruz avatar May 18 '17 08:05 ryanjcruz

@ryanjcruz I'm thinking of adding instructions for Windows users soon. I can use your help with that. Do you mind if I ping you once I figure out the format for it?

jayair avatar May 18 '17 17:05 jayair

@jayair no probs, happy to help out.

ryanjcruz avatar May 19 '17 07:05 ryanjcruz

@ryanjcruz It would help if the instructions show output from commands. Is "UserConfirmed": false, from the response I got expected?

{
    "UserConfirmed": false, 
    "CodeDeliveryDetails": {
        "AttributeName": "email", 
        "Destination": "a***@j***.com", 
        "DeliveryMedium": "EMAIL"
    }
}

Also, having common error responses would be helpful as well. I'm writing because I got this doing verification: An error occurred (UnrecognizedClientException) when calling the AdminConfirmSignUp operation: The security token included in the request is invalid.

The response is from this command:

aws cognito-idp admin-confirm-sign-up \
  --region us-west-2 \
  --user-pool-id us-west-2_bAEhmtfs7 \
  --username [email protected]

The user-pool-id value I got from Pool details: Pool Id, above the Pool ARN.

wilsonmar avatar May 29 '17 11:05 wilsonmar

@wilsonmar That's a good idea. I'll be adding sections to chapters with common errors people are getting.

jayair avatar May 29 '17 11:05 jayair

Can you help me get un-stuck? If not, who can? I'll add to your tutorial is you help me.

On Mon, May 29, 2017 at 7:42 AM, Jay V [email protected] wrote:

@wilsonmar https://github.com/wilsonmar That's a good idea. I'll be adding sections to chapters with common errors people are getting.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AnomalyInnovations/serverless-stack-com/issues/18#issuecomment-304641293, or mute the thread https://github.com/notifications/unsubscribe-auth/AASUDo0eKEjL1QEHzr9m9Plf-YRKHxdIks5r-q8egaJpZM4M4OAz .

wilsonmar avatar May 29 '17 14:05 wilsonmar

@wilsonmar The response you received for the sign-up step looks good. User will only be confirmed after the admin-confirm-sign-up step, which will succeed silently.

Your error An error occurred (UnrecognizedClientException) when calling the AdminConfirmSignUp operation: The security token included in the request is invalid. sounds very much like AWS CLI credentials not specified correctly. Could do refer to these two chapters and double check the CLI configuration. http://serverless-stack.com/chapters/create-an-iam-user.html http://serverless-stack.com/chapters/configure-the-aws-cli.html

At the end of the day, you should have a file at ~/.aws/credentials look similar to

[default]
aws_access_key_id = AKXXXXXXXXXXXXXXXXMQ
aws_secret_access_key = JOsGrxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc132

fwang avatar May 29 '17 21:05 fwang

OK, I Googled around and found this explanation on May 25, 2016 by EdL@AWS: "Cognito User Pools are currently only available in US East (Virginia)." at https://forums.aws.amazon.com/thread.jspa?messageID=722312

Since the first mention of region is at http://serverless-stack.com/chapters/create-an-s3-bucket-for-file-uploads.html I've forked, created branch 'Cognito-User-Pools-only-avail-US-East-1, and updated file as https://github.com/AnomalyInnovations/serverless-stack-com/pull/93

wilsonmar avatar May 30 '17 01:05 wilsonmar

Cognito User Pools were made available in us-west-2, US West (Oregon) later in 2016. https://aws.amazon.com/blogs/aws/amazon-cognito-your-user-pools-now-generally-available/

You shouldn't be able to create the pool in the first place if it were not available.

fwang avatar May 31 '17 00:05 fwang

I'll post the link where that AWS guy posted his fake news. Do you have a link I can go to for properly setting up the creditions file on my machine?

On Tue, May 30, 2017 at 8:06 PM, Frank [email protected] wrote:

Cognito User Pools were made available in us-west-2, US West (Oregon) later in 2016. https://aws.amazon.com/blogs/aws/amazon-cognito-your-user- pools-now-generally-available/

You shouldn't be able to create the pool in the first place if it were not available.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AnomalyInnovations/serverless-stack-com/issues/18#issuecomment-305043666, or mute the thread https://github.com/notifications/unsubscribe-auth/AASUDr2pQlurB5T7Wn1GGU6pgkzKI5ETks5r_K8QgaJpZM4M4OAz .

wilsonmar avatar May 31 '17 07:05 wilsonmar

This should help - http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html

fwang avatar May 31 '17 22:05 fwang

I have multiple AWS profiles for different accounts. Since the one I'm using for this tutorial isn't my default, I needed to add the --profile [profile name from my ~/.aws/credentials file] flag to both CLI commands. Hope this helps!

pjamieson avatar Jul 01 '17 19:07 pjamieson