Skip to main content

A flexible Django Rest Framework Firebase authentication class

Project description

Django Rest Framework Firebase Authentication

PyPI PyPI - License

This package provides a base Firebase Authentication backend class for the Django rest framework. Two key methods are not implemented for more flexebility. Let's keep it simple, stupid.



pip install drf-firebase-authentication


1. Subclass BaseFirebaseAuthentication and implement its template methods:

Decide by yourself how you want to associate Firebase users with local django users by implementing the .get_django_user() method accordingly.

Put your code into a file inside an app dedicated to your projects REST Api.

from drf_firebase.authentication import BaseFirebaseAuthentication
from firebase_admin import credentials, initialize_app
from django.contrib.auth import get_user_model

firebase_creds = credentials.Certificate('path/to/firebase/credentials.json')
firebase_app = initialize_app(firebase_creds)

class FirebaseAuthentication(BaseFirebaseAuthentication):
	Example implementation of a DRF Firebase Authentication backend class
	def get_firebase_app(self):
		return firebase_app

	def get_django_user(self, firebase_user_record):
		return get_user_model().objects.get_or_create(

2. Add the just created Firebase authentication backend to your

Replace YOUR_RESTAPI_APP with the app you put your file in.

		'rest_framework.authentication.SessionAuthentication', # default
		'rest_framework.authentication.BasicAuthentication', # default

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf-firebase-authentication-1.0.1.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page