Google auth provider.

example
// Using a redirect.firebase.auth().getRedirectResult().then(function(result){if (result.credential) {// This gives you a Google Access Token.var token = result.credential.accessToken;  }var user = result.user;});// Start a sign in process for an unauthenticated user.var provider =new firebase.auth.GoogleAuthProvider();provider.addScope('profile');provider.addScope('email');firebase.auth().signInWithRedirect(provider);
example
// Using a popup.var provider =new firebase.auth.GoogleAuthProvider();provider.addScope('profile');provider.addScope('email');firebase.auth().signInWithPopup(provider).then(function(result){// This gives you a Google Access Token.var token = result.credential.accessToken;// The signed-in user info.var user = result.user;});
see

firebase.auth.Auth.onAuthStateChanged to receive sign in statechanges.

Implements

Index

Properties

providerId

providerId:string

Implementation ofAuthProvider.providerId

Inherited fromGoogleAuthProvider.providerId

Static GOOGLE_SIGN_IN_METHOD

GOOGLE_SIGN_IN_METHOD:string

This corresponds to the sign-in method identifier as returned infirebase.auth.Auth.fetchSignInMethodsForEmail.

Static PROVIDER_ID

PROVIDER_ID:string

Methods

addScope

setCustomParameters

  • setCustomParameters(customOAuthParametersObject):AuthProvider
  • Inherited fromGoogleAuthProvider.setCustomParameters

    Sets the OAuth custom parameters to pass in a Google OAuth request for popupand redirect sign-in operations.Valid parameters include 'hd', 'hl', 'include_granted_scopes', 'login_hint'and 'prompt'.For a detailed list, check theGoogledocumentation.Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri','scope', 'response_type' and 'state' are not allowed and will be ignored.

    Parameters

    • customOAuthParameters:Object

      The custom OAuth parameters to passin the OAuth request.

    ReturnsAuthProvider

    The provider instance itself.

Static credential

  • credential(idToken?: string |null, accessToken?: string |null):OAuthCredential
  • Creates a credential for Google. At least one of ID token and access tokenis required.

    example
    // \`googleUser\` from the onsuccess Google Sign In callback.var credential = firebase.auth.GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);firebase.auth().signInWithCredential(credential)

    Parameters

    • Optional idToken:string |null

      Google ID token.

    • Optional accessToken:string |null

      Google access token.

    ReturnsOAuthCredential

    The auth provider credential.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-27 UTC.