This gist was created after spending too much time figuring out how to setup serverless authentication using AWS Cognito and Facebook login. Hope you find it useful!
DISCLAIMER: I have not re-tested the steps but wrote them afterwards. Therefore, it is very likely to contain some issues.
-
Login to AWS and Cognito service
-
Create user pool in Cognito
-
Collect Pool Id (needed later)
-
Define domain in Open App integration > Domain name, say: servicex
-
Navigate to Facebook: https://developers.facebook.com/
-
Create new app in My Apps
-
Add Facebook Login in Products
-
Collect Facebook app id and secret (needed later)
-
Use specificed domain name in Valid OAuth redirect: https://servicex.auth.eu-central-1.amazoncognito.com/
-
Navigate back to AWS Cognito
-
Enable Facebook in Facebook in Federation > Identity providers
-
Create client in App clients (no secret needed)
-
Open App client settings
-
Collect app id (needed later)
-
Enable identity providers
-
Define callback & sign out urls. Example: https://localhost:3000/
-
Select Allowed OAuth Flows: Implicit grant
-
Select Allowed Oauth Scopes: email, openid
-
Create new identity pool in Cognito, say: servicex
-
Open user pool and Edit identity pool
-
Collect the identity pool id
-
Create role for unauthenticated and authenticated (see policy examples)
-
Select Authentication providers and set user Pool id and app client id
-
Write app.js (see attached example) and host it in https://localhost:3000/