-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathauthentication.py
More file actions
41 lines (30 loc) · 1.15 KB
/
authentication.py
File metadata and controls
41 lines (30 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pyrebase
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
config = {
'apiKey': os.getenv("FIREBASE_API_KEY"),
'authDomain': os.getenv("FIREBASE_AUTH_DOMAIN"),
'projectId': os.getenv("FIREBASE_PROJECT_ID"),
'storageBucket': os.getenv("FIREBASE_STORAGE_BUCKET"),
'messagingSenderId': os.getenv("FIREBASE_MESSAGING_SENDER_ID"),
'appId': os.getenv("FIREBASE_APP_ID"),
'measurementId': os.getenv("FIREBASE_MEASUREMENT_ID"),
'databaseURL': os.getenv("FIREBASE_DATABASE_URL")
}
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
email = os.getenv('TEST_USER_EMAIL')
password = os.getenv('TEST_USER_PASSWORD')
# Uncomment to create a new user
# user = auth.create_user_with_email_and_password(email, password)
# print("User created:", user)
# Sign in existing user
user = auth.sign_in_with_email_and_password(email, password)
print("User signed in:", user)
# Uncomment to get account info
# info = auth.get_account_info(user['idToken'])
# print("Account info:", info)
# Uncomment to send password reset email
# auth.send_password_reset_email(email)