Stay organized with collections
Save and categorize content based on your preferences.
Properties
providerId
providerId: string
Static GOOGLE_SIGN_IN_METHOD
GOOGLE_SIGN_IN_METHOD: string
Static PROVIDER_ID
PROVIDER_ID: string
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.
[null,null,["Last updated 2022-07-27 UTC."],[],[],null,["- [firebase](/docs/reference/node/firebase).\n- [auth](/docs/reference/node/firebase.auth).\n- GoogleAuthProvider \nGoogle auth provider.\n\nexample\n:\n\n // Using a redirect.\n firebase.auth().getRedirectResult().then(function(result) {\n if (result.credential) {\n // This gives you a Google Access Token.\n var token = result.credential.accessToken;\n }\n var user = result.user;\n });\n\n // Start a sign in process for an unauthenticated user.\n var provider = new firebase.auth.GoogleAuthProvider();\n provider.addScope('profile');\n provider.addScope('email');\n firebase.auth().signInWithRedirect(provider);\n\n\nexample\n:\n\n // Using a popup.\n var provider = new firebase.auth.GoogleAuthProvider();\n provider.addScope('profile');\n provider.addScope('email');\n firebase.auth().signInWithPopup(provider).then(function(result) {\n // This gives you a Google Access Token.\n var token = result.credential.accessToken;\n // The signed-in user info.\n var user = result.user;\n });\n\n\nsee\n\n: [firebase.auth.Auth.onAuthStateChanged](/docs/reference/node/firebase.auth.Auth#onauthstatechanged) to receive sign in state\n changes.\n\nImplements\n\n- [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n\nIndex\n\nProperties\n\n- [providerId](/docs/reference/node/firebase.auth.GoogleAuthProvider#providerid)\n- [GOOGLE_SIGN_IN_METHOD](/docs/reference/node/firebase.auth.GoogleAuthProvider#google_sign_in_method)\n- [PROVIDER_ID](/docs/reference/node/firebase.auth.GoogleAuthProvider#provider_id)\n\nMethods\n\n- [addScope](/docs/reference/node/firebase.auth.GoogleAuthProvider#addscope)\n- [setCustomParameters](/docs/reference/node/firebase.auth.GoogleAuthProvider#setcustomparameters)\n- [credential](/docs/reference/node/firebase.auth.GoogleAuthProvider#credential)\n\nProperties\n\nproviderId \nproviderId: string\n| Implementation of [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider).[providerId](/docs/reference/node/firebase.auth.AuthProvider#providerid)\n| Inherited from [GoogleAuthProvider](/docs/reference/node/firebase.auth.GoogleAuthProvider).[providerId](/docs/reference/node/firebase.auth.GoogleAuthProvider#providerid)\n\nStatic GOOGLE_SIGN_IN_METHOD \nGOOGLE_SIGN_IN_METHOD: string \nThis corresponds to the sign-in method identifier as returned in\n[firebase.auth.Auth.fetchSignInMethodsForEmail](/docs/reference/node/firebase.auth.Auth#fetchsigninmethodsforemail).\n\nStatic PROVIDER_ID \nPROVIDER_ID: string\n\nMethods\n\naddScope\n\n- addScope ( scope : string ) : [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n-\n Inherited from [GoogleAuthProvider](/docs/reference/node/firebase.auth.GoogleAuthProvider).[addScope](/docs/reference/node/firebase.auth.GoogleAuthProvider#addscope) \n\n Parameters\n -\n\n scope: string \n Google OAuth scope.\n\n Returns [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n\n The provider instance itself.\n\nsetCustomParameters\n\n- setCustomParameters ( customOAuthParameters : Object ) : [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n-\n Inherited from [GoogleAuthProvider](/docs/reference/node/firebase.auth.GoogleAuthProvider).[setCustomParameters](/docs/reference/node/firebase.auth.GoogleAuthProvider#setcustomparameters) \n Sets the OAuth custom parameters to pass in a Google OAuth request for popup\n and redirect sign-in operations.\n Valid parameters include 'hd', 'hl', 'include_granted_scopes', 'login_hint'\n and 'prompt'.\n For a detailed list, check the\n [Google](https://goo.gl/Xo01Jm)\n documentation.\n Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri',\n 'scope', 'response_type' and 'state' are not allowed and will be ignored.\n\n Parameters\n -\n\n customOAuthParameters: Object \n The custom OAuth parameters to pass\n in the OAuth request.\n\n Returns [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n\n The provider instance itself.\n\nStatic credential\n\n- credential ( idToken ? : string \\| null , accessToken ? : string \\| null ) : [OAuthCredential](/docs/reference/node/firebase.auth.OAuthCredential)\n- Creates a credential for Google. At least one of ID token and access token\n is required.\n\n example\n :\n\n // \\`googleUser\\` from the onsuccess Google Sign In callback.\n var credential = firebase.auth.GoogleAuthProvider.credential(\n googleUser.getAuthResponse().id_token);\n firebase.auth().signInWithCredential(credential)\n\n\n Parameters\n -\n\n Optional idToken: string \\| null \n Google ID token.\n -\n\n Optional accessToken: string \\| null \n Google access token.\n\n Returns [OAuthCredential](/docs/reference/node/firebase.auth.OAuthCredential)\n\nThe auth provider credential."]]
Google auth provider.
// 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);
// 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; });
firebase.auth.Auth.onAuthStateChanged to receive sign in state changes.