Firebase User Credentials - Custom Claims
Python script to manage custom claims for Firebase Authentication users.
Setup
Install Dependencies
Get Firebase Private Keys
- Go to Firebase Console
- Project Settings > BackOffice
- Copy firebaseConfig
- Save as
devPrivateKey.jsonorprodPrivateKey.jsondepending on your env
Usage
Get User UID
You can find the user UID in several ways:
- Firebase Console: Authentication > Users > select user
- Client-side: firebase.auth().currentUser.uid
- Admin SDK: auth.get_user_by_email(email).uid
Set Custom Claims
Parameters:
- uid (str): Firebase user ID
- claims (dict): Custom claims dictionary