How to use the @aws-amplify/auth.Auth.currentAuthenticatedUser 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 / withAmazon.jsx View on Github external
.then(credentials => {
						return Auth.currentAuthenticatedUser();
					})
					.then(authUser => {
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-google-button / amplify-google-button.tsx View on Github external
}

    const { id_token, expires_at } = user.getAuthResponse();
    const profile = user.getBasicProfile();

    await Auth.federatedSignIn(
      'google',
      { token: id_token, expires_at },
      {
        email: profile.getEmail(),
        name: profile.getName(),
        picture: profile.getImageUrl(),
      },
    );

    const authenticatedUser = await Auth.currentAuthenticatedUser();

    try {
      this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
    } catch (error) {
      this.handleError(error);
    }
  };
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-auth0-button / amplify-auth0-button.tsx View on Github external
logger.debug('Failed to get the user info', err);
        } else {
          username = user.name;
          email = user.email;
        }

        await Auth.federatedSignIn(
          config.domain,
          {
            token: authResult.idToken,
            expires_at: authResult.expiresIn * 1000 + new Date().getTime(),
          },
          { name: username, email },
        );

        const authenticatedUser = await Auth.currentAuthenticatedUser();

        this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
      });
    });
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-facebook-button / amplify-facebook-button.tsx View on Github external
window['FB'].api('/me', { fields }, async response => {
      const user = {
        name: response.name,
        email: response.email,
      };

      await Auth.federatedSignIn('facebook', { token: accessToken, expires_at }, user);

      const authenticatedUser = await Auth.currentAuthenticatedUser();

      this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
    });
  };
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withFacebook.jsx View on Github external
.then(credentials => {
						return Auth.currentAuthenticatedUser();
					})
					.then(authUser => {
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-amazon-button / amplify-amazon-button.tsx View on Github external
window['amazon'].Login.retrieveProfile(async userInfo => {
      if (!userInfo.success) {
        return logger.debug('Get user Info failed');
      }

      const user = {
        name: userInfo.profile.Name,
        email: userInfo.profile.PrimaryEmail,
      };

      await Auth.federatedSignIn('amazon', { token: access_token, expires_at }, user);

      const authenticatedUser = await Auth.currentAuthenticatedUser();

      this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
    });
  };