Generic OAuth provider.

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

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

param

The associated provider ID, such asgithub.com.

Implements

Index

Constructors

constructor

Properties

providerId

providerId:string

Implementation ofAuthProvider.providerId

Methods

addScope

credential

  • credential(optionsOrIdTokenOAuthCredentialOptions |string |null, accessToken?: string):OAuthCredential
  • Creates a Firebase credential from a generic OAuth provider's access token orID token. The raw nonce is required when an ID token with a nonce field isprovided. The SHA-256 hash of the raw nonce must match the nonce field inthe ID token.

    example
    // `googleUser` from the onsuccess Google Sign In callback.// Initialize a generate OAuth provider with a `google.com` providerId.var provider =new firebase.auth.OAuthProvider('google.com');var credential = provider.credential({idToken: googleUser.getAuthResponse().id_token,});firebase.auth().signInWithCredential(credential)

    Parameters

    • optionsOrIdToken:OAuthCredentialOptions |string |null

      Either the options object containingthe ID token, access token and raw nonce or the ID token string.

    • Optional accessToken:string

      The OAuth access token.

    ReturnsOAuthCredential

setCustomParameters

  • setCustomParameters(customOAuthParametersObject):AuthProvider
  • Sets the OAuth custom parameters to pass in an OAuth request for popupand redirect sign-in operations.For a detailed list, check thereserved required OAuth 2.0 parameters such asclient_id,redirect_uri,scope,response_type andstate are not allowed and will be ignored.

    Parameters

    • customOAuthParameters:Object

      The custom OAuth parameters to passin the OAuth request.

    ReturnsAuthProvider

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.