Search code examples
firebasefirebase-authenticationgoogle-identity-toolkitgoogle-identity

Firebase Authentication with Google Identity (GoogleYOLO)


Is it possible to combine Google Identity (GoogleYOLO) with the Firebase Authentication web stack? If so, how? Thanks!


Solution

  • You can sign in with googleyolo using Firebase Auth as follows:

    hintPromise.then((credential) => {
      if (credential.idToken) {
        // Initialize firebase Auth credential with Google ID token
        // obtained from googleyolo.
        const cred = firebase.auth.GoogleAuthProvider.credential(credential.idToken);
        // Sign in with
        return firebase.auth().signInWithCredential(cred);
      }
      throw new Error;
    }).then((result) => {
      // User signed in.
    }).catch((error) => {
      // Handle error.
    });