How to use the expo-google-sign-in.signInAsync function in expo-google-sign-in

To help you get started, we’ve selected a few expo-google-sign-in 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 wheatandcat / Peperomia / PeperomiaNative / src / containers / Auth.tsx View on Github external
const onGoogleLogin = useCallback(async () => {
    if (isStandaloneAndAndroid()) {
      // TODO: AndroidのstandaloneのみGoogleSignInを使わないとエラーになる
      // https://github.com/expo/expo/issues/4762

      await GoogleSignIn.askForPlayServicesAsync();
      const result = await GoogleSignIn.signInAsync();

      if (result.type === 'success' && result.user && result.user.auth) {
        const { idToken, accessToken } = result.user.auth;
        await firebaseLogin(idToken || '', accessToken || '');
      } else {
        Sentry.captureMessage(JSON.stringify(result));
      }
    } else {
      const androidClientId = process.env.GOOGLE_LOGIN_ANDROID_CLIENT_ID;
      const iosClientId = process.env.GOOGLE_LOGIN_IOS_CLIENT_ID;
      const result = await Google.logInAsync({
        clientId:
          Platform.OS === 'ios' ? String(iosClientId) : String(androidClientId),
        iosClientId,
        androidClientId,
        scopes: ['profile', 'email'],
github expo / expo / apps / native-component-list / src / screens / GoogleSignInScreen.tsx View on Github external
_signInAsync = async () => {
    try {
      await GoogleSignIn.askForPlayServicesAsync();
      const { type, user } = await GoogleSignIn.signInAsync();
      console.log({ type, user });
      if (type === 'success') {
        this._syncUserWithStateAsync();
      }
    } catch ({ message }) {
      console.error('login: Error:' + message);
    }
  }
}
github dooboolab / hackatalk-mobile / src / components / screen / Login.tsx View on Github external
ios: iOSExpoClientId,
            android: androidExpoClientId,
          }),
        });
        Alert.alert('login:' + JSON.stringify(response.accessToken));
      } catch ({ message }) {
        Alert.alert(`Google Login Error: ${message}`);
      } finally {
        setSigningInGoogle(false);
      }
      return;
    }

    try {
      await GoogleSignIn.askForPlayServicesAsync();
      const { type, user } = await GoogleSignIn.signInAsync();
      if (type === 'success') {
        setGoogleUser(user);
        Alert.alert('login:' + JSON.stringify(user));
        onLogin();
        setAuthUser({
          uid: '',
          displayName: '',
          thumbURL: '',
          photoURL: '',
          statusMsg: '',
          friends: [],
          chatrooms: [],
          signedInWith: SignInType.Google,
        });
        resetToMainStack();
      }