How to use the @aws-amplify/auth.federatedSignIn function in @aws-amplify/auth

To help you get started, we’ve selected a few @aws-amplify/auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withGoogle.tsx View on Github external
name: profile.getName(),
				picture: profile.getImageUrl(),
			};

			const { onStateChange } = this.props;
			if (
				!Auth ||
				typeof Auth.federatedSignIn !== 'function' ||
				typeof Auth.currentAuthenticatedUser !== 'function'
			) {
				throw new Error(
					'No Auth module found, please ensure @aws-amplify/auth is imported'
				);
			}

			await Auth.federatedSignIn(
				'google',
				{ token: id_token, expires_at },
				user
			);

			user = await Auth.currentAuthenticatedUser();

			if (onStateChange) {
				onStateChange('signedIn', user);
			}
		}
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withAuth0.tsx View on Github external
this._auth0.client.userInfo(authResult.accessToken, (err, user) => {
						let username = undefined;
						let email = undefined;
						if (err) {
							logger.debug('Failed to get the user info', err);
						} else {
							username = user.name;
							email = user.email;
						}

						Auth.federatedSignIn(
							config.domain,
							{
								token: authResult.idToken,
								expires_at: authResult.expiresIn * 1000 + new Date().getTime(),
							},
							{ name: username, email }
						)
							.then(() => {
								if (onStateChange) {
									Auth.currentAuthenticatedUser().then(user => {
										onStateChange('signedIn', user);
									});
								}
							})
							.catch(e => {
								logger.debug('Failed to get the aws credentials', e);
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withFacebook.tsx View on Github external
fb.api('/me', { fields: 'name,email' }, response => {
				const user = {
					name: response.name,
					email: response.email,
				};
				if (
					!Auth ||
					typeof Auth.federatedSignIn !== 'function' ||
					typeof Auth.currentAuthenticatedUser !== 'function'
				) {
					throw new Error(
						'No Auth module found, please ensure @aws-amplify/auth is imported'
					);
				}

				Auth.federatedSignIn(
					'facebook',
					{ token: accessToken, expires_at },
					user
				)
					.then(credentials => {
						return Auth.currentAuthenticatedUser();
					})
					.then(authUser => {
						if (onStateChange) {
							onStateChange('signedIn', authUser);
						}
					});
			});
		}
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withAuth0.jsx View on Github external
this._auth0.client.userInfo(authResult.accessToken, (err, user) => {
                        let username = undefined;
                        let email = undefined;
                        if (err) {
                            logger.debug('Failed to get the user info', err);
                        } else {
                            username = user.name;
                            email = user.email;
                        }

                        Auth.federatedSignIn(
                            config.domain,
                            {
                                token: authResult.idToken,
                                expires_at: authResult.expiresIn * 1000 + new Date().getTime()
                            },
                            { name: username, email }
                        ).then((cred) => {
                            if (onStateChange) {
                                Auth.currentAuthenticatedUser().then(user => {
                                    onStateChange('signedIn', user);
                                });
                            }
                        }).catch((e) => {
                            logger.debug('Failed to get the aws credentials', e);
                            if (onError) onError(e);
                        });
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withAmazon.tsx View on Github external
const user = {
					name: userInfo.profile.Name,
					email: userInfo.profile.PrimaryEmail,
				};
				if (
					!Auth ||
					typeof Auth.federatedSignIn !== 'function' ||
					typeof Auth.currentAuthenticatedUser !== 'function'
				) {
					throw new Error(
						'No Auth module found, please ensure @aws-amplify/auth is imported'
					);
				}

				Auth.federatedSignIn(
					'amazon',
					{ token: access_token, expires_at },
					user
				)
					.then(credentials => {
						return Auth.currentAuthenticatedUser();
					})
					.then(authUser => {
						if (onStateChange) {
							onStateChange('signedIn', authUser);
						}
					});
			});
		}