Created
June 16, 2020 16:35
-
-
Save raghavmri/3f8dfc525a6e4d01d147f615e2fe5963 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyrebase | |
config = { | |
"apiKey": "Your API Key", | |
"authDomain": "YourprojectId.firebaseapp.com", | |
"databaseURL": "https://YourdatabaseName.firebaseio.com", | |
"storageBucket": "YourprojectId.appspot.com", | |
"serviceAccount": "path/toyour/serviceAccountCredentials.json" | |
} | |
# initialisatiing pyrebase | |
firebase = pyrebase.initialize_app(config) | |
auth = firebase.auth() | |
# To save extra data except password and username(optional) | |
# Get a reference to the database service | |
db = firebase.database() | |
# data to save | |
data = { | |
"phone": "123456789" | |
} | |
# Pass the user's idToken to the push method | |
results = db.child("users").push(data, user['idToken']) | |
# How to Create a User | |
auth.create_user_with_email_and_password(email, password) | |
# For sending verification email | |
auth.send_email_verification(user['idToken']) | |
# Password change | |
auth.send_password_reset_email("email") | |
# Get account info | |
auth.get_account_info(user['idToken']) | |
# Refreshing a token | |
user = auth.refresh(user['refreshToken']) | |
# Creating custom tokens | |
token = auth.create_custom_token("your_custom_id") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment