내용으로 건너뛰기

Cognito federation with google provider throwing redirect error

0

In our user pool phone_number is mandatory. In Google outh2.0 authorized scope for phone numbers is added(https://www.googleapis.com/auth/user.phonenumbers.read). On the client side, we are using the Amplify federationSignIn method with the CognitoHostedUIIdentityProvider Google module.

After clicking the Google oauth2.0 CTA it redirected Google asking phonenumber access after the process was completed. Cognito redirected me to my page with the URL of http://localhost:8010/?error_description=attributes+required%3A+%5Bphone_number%5D&state=TZDvvUDtK21fO7TocBiwimahqwv5kDxk&error=invalid_request

How to fix the error_description=attributes+required%3A+%5Bphone_number%5D& redirect issues.

질문됨 3년 전988회 조회

1개 답변
0

To resolve the error_description=attributes+required:[phone_number] issue with AWS Cognito and Google OAuth 2.0, you can follow these steps:

-Verify Scope Configuration: Ensure that the scope for phone numbers is correctly added in the Google API and that it matches the scope in your application configuration. The scope you've added (https://www.googleapis.com/auth/user.phonenumbers.read) should be correctly integrated into your OAuth flow.

-Check Cognito User Pool Settings: Make sure that the Cognito User Pool is configured to mark the phone number as a required attribute. This setting should align with your application's authentication flow.

-Review Attribute Mapping: In AWS Cognito, check the attribute mapping for the Google identity provider. Ensure that the phone number attribute from Google is correctly mapped to the Cognito user pool attribute.

-Handle Redirects Appropriately: In your application, ensure that the OAuth flow is correctly handling redirects. After the user grants permission on Google's consent screen, your application should handle the redirect from Google correctly, capturing any error messages or codes.

-Error Handling: Implement error handling on the redirect URI to catch and manage errors like the one you're experiencing. This can help in understanding if there are additional underlying issues in the OAuth flow.

-Testing and Debugging: Test the flow thoroughly with different scenarios to ensure that the phone number is correctly being passed and accepted by Cognito. Use debugging tools to trace the flow and identify where the breakdown is occurring.

-Consult AWS Cognito Documentation: Refer to AWS Cognito's official documentation for detailed guidance on setting up and troubleshooting the OAuth flow and attribute mapping.

AWS

답변함 3년 전

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

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