Sign in via Google

Client side code for signing in via the Google provider using the Firebase SDK

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


function signIn() {
  const provider = new firebase.auth.GoogleAuthProvider();
    .then(result => {
      // Returns the signed in user along with the provider's credential
      console.log(`${result.user.displayName} logged in.`);
      window.alert(`Welcome ${result.user.displayName}!`);
    .catch(err => {
      console.log(`Error during sign in: ${err.message}`);
      window.alert('Sign in failed. Retry or check your browser logs.');

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.