Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login with Facebook using Cognito is redirecting to URL with an error

I've created a User Poll and connected a Facebook to it. Here is what it looks like in the AWS Console.

CognitoFacebook

I also have set email as a required attribute for signing up.

However, when I visit my hosted login page and click Continue with Facebook, I get redirected back to my page with URL

http://localhost:4200/#error_description=attributes%20required:%20[email]&error=invalid_request

Why is this happening? I've followed all the instructions, and have included email as a scope. I am expecting an access_token in the URL.

Please help. Thanks!

like image 314
CodyBugstein Avatar asked Nov 30 '22 08:11

CodyBugstein


2 Answers

The error message says that the email address is required which indicates that email is a required attribute on your user pool. You have done the correct thing by including the "email" scope but you also have to include the attribute mapping for the provider (Facebook in your case) in the Amazon Cognito console by mapping facebook email to Cognito email attribute. Please give this a shot and let us know if it worked or not.

like image 192
Rachit Dhall Avatar answered Dec 06 '22 10:12

Rachit Dhall


What caused this issue for me, was that I was requesting an attribute from Facebook, which did not exists. In my case:

picture.size(large) # This does not exists and will cause errors

Facebook then responds with an error to Cognito, and Cognito just tells you that the required attribute email was not in the request. So if you get this error message, the issue is most likely not with the email, but something else which is setup wrong and you therefore get an invalid request

like image 21
Attaque Avatar answered Dec 06 '22 11:12

Attaque