Skip to content
Advertisement

How to authenticate to Firebase using Python?

I am building a Web App with Python and I would like to authenticate users. The pyrebase package seems to be outdated and it generates dependency errors so I cannot use it. I know that there is a function from the firebase-admin API that works like this:

from firebase import auth
email = example@example.com
user = auth.get_user_by_email(email)

But what if this user has a password? I would like to check if the both the email and the password are provided correctly. Thanks in advance.

Advertisement

Answer

The Firebase Admin SDK does not have the concept of a current user, so there’s no API to “sign in” a user based on their credentials.

Since you’re building a web app, the usual flow is to use the Firebase JavaScript SDK in your client-side code to sign the user in. If needed you can then send the ID token from the client to your Python code on the server, and perform user-based operations there.

Advertisement