I am trying to use the authentication feature in firebase for email and password/. i have the following code:
import pyrebase
firebaseConfig = {
'apiKey': "AIzaSyDO80bIZpwVVTS2vpAzRiKBpha9nCIIHpg",
'authDomain': "kintil-s-project2.firebaseapp.com",
'databaseURL': "https://kintil-s-project2-default-rtdb.firebaseio.com",
'projectId': "kintil-s-project2",
'storageBucket': "kintil-s-project2.appspot.com",
'messagingSenderId': "55270635464",
'appId': "1:55270635464:web:e283b8301ead1df396f2fd",
'measurementId': "G-WP9GZWXVBX"
}
firebase = pyrebase.initialize_app(firebaseConfig)
Auth = firebase.auth()
email = input('enter email')
password = input('enter password')
#Auth.create_user_with_email_and_password(email, password)
when i ran the above, i got the following error:
from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named 'Crypto'
what can i do to solve this problem.
PS i was having issue installing pycrytodome from cmd using pip, so i installed from pycharm.
Yes there is a problem with pycryptodome
module while installing it with pip, so without the pycryptodome
module pyrebase
will not work properly. But there is good alternative for pyrebase
, that is firebase-admin
module by Google and it works like a charm with almost similar functionalities. It is very easy to switch to the firebase-admin
module and here are the official docs of Firebase Admin Python SDK.
import firebase_admin
from firebase_admin import credentials, auth
""" To get the your service.json file, follow these steps
1) Go to your firebase console and login
2) Click on the Gear(settings) icon beside Poject Overview
3) Then go to, Project Settings -> Service Accounts -> Click Generate new private key
4) Your service.json file will be downloaded, added it to your main.py file directory
"""
# Initializing the firebase-admin
cred = credentials.Certificate('path/to/your/service.json')
firebase_admin.initialize_app(cred)
# Taking the email and password from user
your_email = input('enter email')
your_password = input('enter password')
# Creating the user with email and password
user = auth.create_user(email= your_email, password= your_password)
print(user.uid)
For more information visit the official Docs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.