Firebase: Sign in with Google

Here is a quick guide to use the “Sign in with google” functionality using the anvil-firebase library.

  1. Go to firebase console and add authentication to your project.

In the Authentication View

  1. Under Sign-in method, enable Email/Password and Google as your provider. (Email/Password is required to view/add users)
  2. Go to the Settings Tab and add your custom log-in domain to authorized domains.

In your Log in Form

  1. Add a button with a click event
  2. Set your click event to the following:
  def button_google_auth_click(self, **event_args):
    """This method is called when the button is clicked"""
    provider = authentication.proxy_auth.GoogleAuthProvider()
    authentication.auth.languageCode = 'en' #choose your language
    result = authentication.proxy_auth.signInWithPopup(authentication.auth,provider)

Badabing-Badaboom! you have now been authenticated via your google auth using your firebase client.

Here are the firebase docs

Thanks community!

4 Likes