Flutter Mobile App with Firebase Auth[Google Sign In] + Django Rest Framework for backend
Please I am new to django[rest framework] for backend and I need help. I am working on a flutter mobile app and I'm using firebase as my authentication platform - is there a way in which I am already using flutter to develop the mobile app, firebase as the authentication just for signing users and then Django[Django rest framework] as the backend in such a way that signed in users on firebase can authenticate with Django [Django rest framework] to retrieve and modify data.
I want to use django because I already have a foundation in python and I hate firebase rules
To integrate Firebase authentication with Django REST Framework (DRF), follow these steps:
Authenticate Users in Flutter: Use Firebase for sign-in on the mobile app and get an ID token for each authenticated user.
Install a Firebase Authentication Package for Django: Install a package like
django-firebase-auth
withpip install django-firebase-auth
. Insettings.py
, configure it by pointing to your Firebase Admin SDK key file:FIREBASE_AUTH = { "SERVICE_ACCOUNT_KEY_FILE": "path_to_your_credentials.json" }
Set Firebase as DRF’s Authentication Class: Add it as the default authentication method in DRF:
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ['firebase_auth.authentication.FirebaseAuthentication'], }
Access Firebase Users in Django Views: Use
request.user
in views to interact with authenticated Firebase users.
This setup allows secure access to Django's backend using Firebase without Firebase rules.