Here is a quick guide to use the “Sign in with google” functionality using the anvil-firebase library.
- Go to firebase console and add authentication to your project.
In the Authentication View
- Under Sign-in method, enable Email/Password and Google as your provider. (Email/Password is required to view/add users)
- Go to the Settings Tab and add your custom log-in domain to authorized domains.
In your Log in Form
- Add a button with a click event
- 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!