Firebase with Python

Tarun Bisht
Nov 3 · 2 min read
Image From https://firebase.google.com/
Image From https://firebase.google.com/
https://firebase.google.com/

Firebase is a mobile and web application development platform by Google. Firebase platform has approx 18 products ready to be implemented in the project.

Features of firebase can be implemented in python using Firebase Admin SDK for Python. In this post, we will tackle Firebase Authentication and Storage which are essential for most of the projects.


Create a Firebase App

  1. Open your Firebase Console and create an app or find an existing app.
  2. Download the Firebase config file which is in JSON format this file is needed to be mentioned inside your project. In the project‘s console, the config file can be downloaded from Settings > Project Settings >Service Accounts > Firebase Admin SDK > Generate New Private Key

Install the Firebase SDK:

Install the Firebase Admin SDK for python using pip.


Configure SDK in Python Project

Importing Firebase Admin to project

Creating a Firebase app instance


Implementing Firebase Auth

Firebase Auth is a service that can authenticate users using only client-side code.

Importing Firebase Auth to project

Creating a User

Retrieving User Data

Functions used to retrieve user data returns UserRecord object using which we can access user information.

Using User Id

Using Email Id

All Users

Updating User Data

Deleting User Data


Implementing Firebase Storage

Firebase Storage provides secure file uploads and downloads for Firebase apps. The developer can use it to store images, audio, video, or other user-generated content.

Importing Firebase Storage to project

Configuring Firebase Storage bucket

Uploading File to Firebase Storage

Delete File from Firebase Storage

Making a File Public

Generating access URL for a file

The saved file inside bucket needs to be accessed in some manner most common way to access a file is through URL. Firebase provides a way to generate

Signed URL- URL which is valid for a specific time after which they get expired.

Public URL- URL which is valid till the file is present in storage. To get a public URL file should be public.

This article just provides configuration of Firebase and basic implementation of some features of Firebase. For more references please refer to Firebase docs.

Thanks for being till last.😊😊

References:

https://firebase.google.com/docs

https://googleapis.dev/python/storage/latest/blobs.html

Tarun Bisht

Written by

I am an Artificial Intelligence enthusiast, researcher, programmer and developer. Also highly interested in Quantum Computer and Physics, Astrophysics.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade