question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS Amplify Facebook Login, Federated Identities

See original GitHub issue

** AWS Authentication **

I am using Cognito User Pools to manage user Sign-Up and Sign-In. I also want to login with facebook. The documentation says that we don’t need to use Auth.federatedSignIn() , so I am not sure what else to be used and how?

image

here;s my code so far

  loginFB = async (params) => {
		try {
			const {
				type,
				token,
				expires,
				permissions,
				declinedPermissions,
			} = await Facebook.logInWithReadPermissionsAsync('414271525994061', {
				permissions: ['public_profile,email'], behavior: 'native'
			});

			console.log('type:', type);
			console.log('token:', token);

			if (type === 'success') {
        // Get the user's name using Facebook's Graph API
        
				const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`);
        // Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`);
        
        const user = {
          name: response.name,
          email: response.email
        };

        const date = new Date();

        const expires_at = expires * 1000 + date.getTime();

        Auth.federatedSignIn('facebook', { token, expires_at }, user)
                .then(credentials => {
                    console.log(credentials);
                });

			} else {
				// type === 'cancel'
			}
		} catch ({ message }) {
			alert(`Facebook Login Error: ${message}`);
		}
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
powerful23commented, Mar 28, 2019

@khalaniaiyaj to federated with the user pool, you should use the Cognito Hosted UI. Could you check https://aws-amplify.github.io/docs/js/authentication#using-amazon-cognito-hosted-ui?

2reactions
khalaniaiyajcommented, Mar 18, 2019

I am facing same issue, i am using user pools for sign-up and sign-in. Now i want to use facebook, instagram, twitter etc. with aws cognito. Here if i want to combine all users from external provider, then how can we achieve that? Can you please explain me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Authentication - Advanced workflows - JavaScript - Amplify Docs
You can alternatively use Auth.federatedSignIn() to get AWS credentials directly from Cognito Federated Identities and not use User Pool federation.
Read more >
Facebook Login with Cognito using AWS Amplify - SST.Dev
Next we are going to use Cognito Identity Pool to federate our identities. This means that when a user signs up with their...
Read more >
Facebook (identity pools) - Amazon Cognito
Amazon Cognito identity pools integrate with Facebook to provide federated authentication for your mobile application users. This section explains how to ...
Read more >
The Complete Guide to Implement Social Login With AWS ...
Learn about how to set up a full-stack serverless ReactJS application using AWS Amplify with Google and Facebook Login functionality.
Read more >
The Complete Guide to User Authentication with the Amplify ...
The easiest way to do this will be by using the Auth.federatedSignIn() method from the Auth class from AWS Amplify.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found