How do I add all three alias attributes in AWS Cognito while creating AWs amplify add auth?

0

I am using the AWS Amplify React application. while adding auth in my application users can log in with their mobile number and email, both of them. but I created auth in my application by using 'amplify add auth' command it asks only to select any one of the attributes below

amplify add auth Using service: Cognito, provided by: awscloudformation

The current configured provider is Amazon Cognito.

Do you want to use the default authentication and security configuration?** Manual configuration** Select the authentication/authorization services that you want to use: User Sign-Up, Sign-In, connected wi th AWS IAM controls (Enables per-user Storage features for images or other content, Analytics, and more)
Provide a friendly name for your resource that will be used to label this category in the project: otplogi n7e50e4547e50e454 Enter a name for your identity pool. otplogin7e50e454_identitypool_7e50e454 Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM)** No**
Do you want to enable 3rd party authentication providers in your identity pool? No Provide a name for your user pool:** otplogin7e50e454_userpool_7e50e454** Warning: you will not be able to edit these selections. How do you want users to be able to sign in? Username

Email Phone Number Email or Phone Number I want to learn more.

But in aws cognito UI level I can select all three of them for reference,

Enter image description here

Now I want to use all three of them, how can I use that amplify cognito add auth command? or any other way to achieve that?

1 Answer
1
Accepted Answer

Hi,

To add all three attributes email, phone_number, preferred_username as sign in options while adding auth category using Amplify CLI, you would have to add all three under aliasAttributes in cli-inputs.json and remove usernameAttributes and autoVerifiedAttributes keys. Steps for the same are mentioned below.

  1. Select Email or Phone Number as the sign in option while adding auth.

  2. Under amplify/backend/auth/<auth-name>/cli-inputs.json, make the following changes.

    a. "aliasAttributes": ["email", "phone_number", "preferred_username"],

    b. Remove usernameAttributes and autoVerifiedAttributes

  3. Execute "amplify push".

Reference :- https://github.com/aws-amplify/amplify-cli/issues/1546

AWS
SUPPORT ENGINEER
Mukul_V
answered 5 months ago
  • Hi Mukul_V, Thank you for sharing your response. I would like to mention that I have successfully configured my end.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions