Facebook Login with Cognito using AWS Amplify


#1

Link to chapter - https://serverless-stack.com/chapters/facebook-login-with-cognito-using-aws-amplify.html


#2

@jkassel Just replying here so others can find this thread.

Thanks for pointing the typos out. I just fixed it.

Yeah a separate user is created through this process. This is because the federation happens in the Identity Pool. You are not connecting to the User Pool. One way to throw the error would be to check if a user with that email already exists before this line:

I should also that there another way to do this. You can use the User Pool to log the Facebook user in. But the way we talk about in this chapter is the one Amplify supports by default.

For the session expiry issue I don’t see the problem. Can you try the hosted version and see if you have the issue?

https://demo-fb-login.serverless-stack.com


#3

Thanks. I’m unable to test against the hosted version since i believe my account needs to be whitelisted because your Facebook app is in development mode. I will also review the code and see if anything is different to confirm it isn’t me.


#4

Oh yeah. I need to get the app approved.


#5

This is such a great resource! I am having some trouble authenticating with Google. Do you have any resources on the differences between the two SDKs?


#6

Hmmm I haven’t try Google yet. What is the issue you are running into?


#7

Struggling with how to load the API


#8

As in the authentication works but when you make a call to the Serverless API it fails?

We might work on adding the Google login option as well. But it’ll be good to know what the issues are.


#9

Are you going to implement Google Login option ?


#10

Yeah we are looking into it. No timeline on it yet though!


#11

I skimmed through this chapter and find out that we set Facebook as an authentication provider on “Identity Pool”. By the way, I also saw an option to set up an identity provider on “User Pool” with Facebook. What is the difference between these alternatives? Can I set up Facebook app id on User Pool instead of Identity Pool?


#13

Hey All - this is such a great resource!

I’m trying to snag a facebook user’s email address during the login process.

I’ve added a ‘console.log(user);’ after line 55 in the FacebookButton.js file, but I’m only getting an ‘undefined’ value output to the console.

Any other thoughts on how I can get the user’s email? It seems like it should be present?

Thanks!


#14

Yeah you can use the User Pool instead of the Identity Pool. The way we describe in this chapter is the one AWS Amplify uses. The key difference being that the User Pool will store the users details as opposed to the Identity Pool way where the User Pool is not involved.


#15

I asked around in our chatroom (https://gitter.im/serverless-stack/Lobby) and they had some ways to do this. It sounds like you need to make a separate API call to /me to get this info.


#16

Dude! Thanks a ton! I appreciate the help!!