Python Firebase SDK Working with Authentication

In this Python Firebase SDK we learn about Working with Python Firebase Authentication.

 so using Firebase Authentication you can create and manage users account in Firebase 

Project. before this we had two articles on using Firebase SDK with Python Programming

Language, you can check the articles in the below links.

 

 

 

Python Firebase SDK Tutorials 

1: Firebase SDK Integration with Real Time Database

2: Firebase SDK working with Cloud Firestore 

 

 

 

You can check Firebase Admin SDK features that are available for different programming

languages in this link, Firebase Admin SDK Features .

 

 

 

Also you can watch the complete video for Python Firebase SDK Working with Authentication.

 

 

 

 

Setup Firebase Project & Service Account

To use the Firebase Admin SDKs, you’ll need the following:

  • A Firebase project
  • A service account to communicate with Firebase
  • A configuration file with your service account’s credentials

 

 

 

OK so after creation of your project in Firebase Console, you need to enable Email and Password 

from Authentication section of  your project.

after that for integration of Firebase SDK you need to install the SDK for the language of your

choice. because we are using Python, so we do the process for python programming language.

you can easily install Firebase Admin SDK with pip like this.

 

 

 

To authenticate a service account and authorize it to access Firebase services, you must

generate a private key file in JSON format.

 

  1. In the Firebase console, open Settings > Service Accounts.
  2. Click Generate New Private Key, then confirm by clicking Generate Key.
  3. Securely store the JSON file containing the key.

 

 

 

Admin SDK Integration 

So before working with the Firebase Authentication, we need to authenticated our application with

our Firebase Project . after creating of our JSON file from Service Account, copy the file and add

that to your working directory.

 

 

 

 

 

So in the above code this is for fetching the service account key JSON file. and make sure

that you have downloaded the key and added that to your working directory.

 

 

 

 

So this code is for creating users in your Firebase Project. we can use create_user() function

from auth class. in here we have just given email, password and phone number as arguments

for creating user, but you can add more parameters, for example you can add display name or

you can add a  profile pic.

 

 

 

In this code snippet we are going to get the user according to email and also phone number.

 

 

 

 

For example you have a lot of users in your Firebase Project, now if you want to list these

users you can do like this.

 

 

 

Sometimes you need to create the user by your own id , so for that you can use this code.

 

 

 

 

This code is used for resetting of user password, it generates a link for resetting of password

in Firebase Project. you can use generate_password_reset_link() function for this. you can

pass some parameters for this, the first one the email address that we want to reset the

password and the second one is the action_code_settings. so the ActionCodeSettings

instance (optional). Defines whether the link is to be handled by a mobile app and the

additional state information to be passed in the deep link.

 

 

 

 

In this code snippet we can create email verification link.

 

 

 

 

So now this is the complete source code for this article.

 

 

 

 

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

1 thought on “Python Firebase SDK Working with Authentication”

  1. hey thanks for the your service, can you help me on posting photos,videos,music, for making an ecommerce app

Comments are closed.

Share via
Copy link
Powered by Social Snap
×