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개 답변
1
수락된 답변

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
지원 엔지니어
Mukul_V
답변함 6달 전
  • Hi Mukul_V, Thank you for sharing your response. I would like to mention that I have successfully configured my end.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠