AWS Cognito - Facebook integration(login with Facebook)
AWS Cognito user pool, instead of using sign up process, if we want to use third party provider for sign in then you should configure this using Identify provider option and in this case we trying to use Facebook integration provide with AWS Coginito, so that end user can use their existing Facebook login to login into your website.
But before we begin here, we first have to create/configure account on third party provider and then same need to be configure here. Like in case of Facebook, we need to create developer account on Facebook which we then need to configure here.
Demo:
- Create developer account with faceboook (https://developers.facebook.com/)
- Create new app and then from basic setting, copy app id and secret which you would require with AWS cognito to setup. With basic tab, do setup other things i.e.
- With App domains : enter the Cognito domain. (refer previous article to know about app domain).
- +Add platform and select website and provide Cognito domain url with sub directory "/oauth2/idpresponse".
- Add facebook login: From products list select facebook login(if this is not available then click on add product and then select facebook login) and then from setting, add valid Oauth redirect url(your Cognito domain url with sub directory "/oauth2/idpresponse"):
- Now login to AWS console and go to Cognito server, select manager user pool and open existing user pool or create new pool.
- From App and client setting app integration, select Facebook and save:
- From Identity provider, select facebook and provide app id and secret key you copied from Facbook App you created for this and in Authorize Score, provide what information you would like to capture from end user on login, so in this case, I am trying to capture "public_profile" and "email":
- Provide attribute mapping(fields mapping - Facebook vs AWS Congnito form attributes). This will be captured from facebook during end user login with Facebook:
- Now to test the sing in url, use below format to prepare your url and use same into browser and it should open sign in page.
Here response_type=token, which after a successful sign-in, Amazon Cognito returns user pool tokens to your web browser's address bar.
Post, successful login, it will redirect back to your callback url alogin with token information in query string:
- Successful Facebook logged in user, you can find in Cognito app pool users and group:
Categories/Tags: AWS Cognito~Facebook integration