Skip to content

Google Sign In Get Started

Eoin Landy edited this page Jan 30, 2020 · 3 revisions

The contents of this page are based on the original Firebase Documentation

You can let your users authenticate with Firebase using their Google Accounts by integrating Google Sign-In into your app.

Before you begin

  1. If you haven't yet connected your app to your Firebase project, do so from the Firebase Console.
  2. If you haven't yet specified your app's SHA-1 fingerprint, do so from the Settings page of the Firebase console. See Authenticating Your Client for details on how to get your app's SHA-1 fingerprint. (Android only)
  3. Enable Google Sign-In in the Firebase Console:
    • In the Firebase console, open the Auth section.
    • On the Sign in method tab, enable the Google sign-in method and click Save.

Add Google Sign In to your app

import com.tuarua.google.GoogleSignInANE;
import com.tuarua.google.signin.events.GoogleSignInEvent;

private var googleSignIn:GoogleSignInANE;

To launch the Google Sign In screen:

googleSignIn = GoogleSignInANE.googleSignIn;
googleSignIn.addEventListener(GoogleSignInEvent.SIGN_IN, onGoogleSignIn);
googleSignIn.addEventListener(GoogleSignInEvent.ERROR, onGoogleSignIn);
googleSignIn.signIn();

Authenticate with Firebase

In the onGoogleSignIn method, we pass this GoogleAuthCredential to auth.signIn():

private function onGoogleSignIn(event:GoogleSignInEvent):void {
    if (event.error) {
        statusLabel.text = "Google Sign In error: " + event.error.errorID + " : " + event.error.message;
        return;
    }
    auth.signIn(event.credential, onSignedIn);
}

Next steps

After a user signs in for the first time, a new user account is created and linked to the credentials—that is, the user name and password, phone number, or auth provider information—the user signed in with. This new account is stored as part of your Firebase project, and can be used to identify a user across every app in your project, regardless of how the user signs in.

To sign out a user, call signOut()

auth.signOut();
Clone this wiki locally