Skip to content

Commit 63ce68f

Browse files
authored
Add files via upload
1 parent e5c0ae0 commit 63ce68f

18 files changed

+1081
-0
lines changed
3.29 KB
Binary file not shown.
11 KB
Binary file not shown.
9.91 KB
Binary file not shown.

Projects/digiRaven/copy.ico

12.3 KB
Binary file not shown.

Projects/digiRaven/cred.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"type": "service_account",
3+
"project_id": "sftproject-a6eeb",
4+
"private_key_id": "e5d665648543268f08e4bbe41990a9e21d62a4be",
5+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCOcFCjQBD8MBvN\nUiCwtZ9ossbLetdFkuiXVQLE3PDUEHyxtqycgIHXfIPeF35b/dHix6hJd6AFPtac\nI/oO2rKoTDus8DCIAr+xjNMQxPv9dejyDjz/5aANLpE97Hlcb72QuDKvP/+V4myd\nMUmTZqSNhaReXczuXfy93Ypq+kUxQefPcZejVIpGWSApq6pVNwL0lF8J1rUQGdPt\n6XzUsr1qhun4f4u3aqGWE5khZGoQ6CUfw2eeW5aWZo0x16RMKQceEzrFTxzfrfRB\nTmz9vanEqd1oyuk6mqU65+yQnx0BhhQw+GDr1XmAdwbpTD4qpkn0eRIpHm01JoDn\nIqq8OV8pAgMBAAECggEAARfl5aCigleXbZMmgPA1slT8HC2PHx2JqYD7n53gYYkB\n5X4GAC/WPS2ZT7JsWltd7Pcr5GZGuwzpDm4e94CsRWKQFc3K4sZij1tHw+lt+ft3\nej8Lt19wiDs85tssqEaDEb0048rOPoNdUYUTfeWvxziwfIgd8WmQwz+R2nTQud6M\nblYF3wIvWyiC/M+OvjLMoVqIce4RPKR2fH/usHBAdLDzegw+bkDpQD5FIo9aktI3\ndaIrJslzHS7v9nB3/ZjzE1KY2m9aFeCfvqm7MRFJBHZGHEmghr35Nl8xT2M/Joa3\nyPiQ+nb2vj11GcpQGgc8DLzsUO7QPBH9T92lBoo/cQKBgQDGYDLaHkabXNcQ+X7U\nD/DeEhisIhlDh851lbjsgPML1WeOcyok688t2KROb9Zt2YvBTT/cHG44amwC7/sn\nAvA5axB/wE0AnlqmJZ9hRyfOs07I6+rHIB5Bxm1v5PrJ0BgV36cdZPmELt3HTcwY\ntKl/tHJlYEr9DYPhd5vZwkECUQKBgQC30Hl3bPsfVyfeoyxl9u9JsD658UeTnUlB\nNnh70R0QjqKJB1TCaLnisTCF6sFJBA6uEaTdDuSEWeneGHkIiOjwXmAekBSNJ2N3\nyuj+L5ogFTK0kK+hELpiulveoOr6Lme3NNCXioBwfASyOzDh+5GjVqODDGZMXf00\njcw9zjlBWQKBgESnXFICclsoaUH1psALeEfSqXlBH88wO/KTy3kGM5cf1wQEtUwr\n0/rA5DRFHkfMJ0LR0k0CBd8+bX0iwp/As5Sbig08ZynUo/imQp9u+cbeZWDBzPH3\nGqGW45769xRLEVrYmURiAryNX7GvKfhO5e5Na93L0of7Wm34cBaP1OHRAoGAHiDn\np/GO/8YTXOS2BEiDVDq1LVkk+EcRmMTK3tCZyPr4HSm8dNkhjsyoPWsLH2Kw3Us7\nEJi+UAtE0AiG3iVCuRNfAeNv2usX3Ky/n9pBkvymgP4uK2JIiqItKMKLgVJV4aug\nfRZQkx9gza3yBzhq2LD8wCAqLF5DgHe1gHPq4pECgYBTyfWYEMNzlf1Vll0Dqnbe\n+Dq3PYcioXjAo5EgXoGZiLN2nfY2VmbkNSi6UUmG2Or5luIPRDoaMF3H6s7j3KHK\nGi75rssok2evvhCRg+HPmdEbVFNlrhLMl7YJlFmuM7PDG1ql7JYP1qi66tPb8s7U\nb+xgJOI9E8hgv78nKAVT8g==\n-----END PRIVATE KEY-----\n",
6+
"client_email": "firebase-adminsdk-md3ed@sftproject-a6eeb.iam.gserviceaccount.com",
7+
"client_id": "111619140252402351114",
8+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
9+
"token_uri": "https://oauth2.googleapis.com/token",
10+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-md3ed%40sftproject-a6eeb.iam.gserviceaccount.com",
12+
"universe_domain": "googleapis.com"
13+
}

Projects/digiRaven/database.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#database.py
2+
3+
import firebase_admin
4+
from firebase_admin import credentials, db, auth
5+
import pyrebase
6+
7+
class Firebase:
8+
def __init__(self):
9+
# Initialize Firebase Admin SDK with credentials and database URL
10+
CREDENTIALS_FILE = "cred.json"
11+
DATABASE_URL = "https://sftproject-a6eeb-default-rtdb.europe-west1.firebasedatabase.app/"
12+
API_KEY = "AIzaSyBgENniVkNeOgctnOFAl7GZm68J0wkAJHI"
13+
PROJECT_ID = "SFTProject"
14+
self.cred = credentials.Certificate(CREDENTIALS_FILE)
15+
firebase_admin.initialize_app(self.cred, {"databaseURL": DATABASE_URL})
16+
17+
# Reference to the root of the Firebase Realtime Database
18+
self.ref = db.reference("/")
19+
self.config = {
20+
"apiKey": API_KEY,
21+
"authDomain": f"{PROJECT_ID}.firebaseapp.com",
22+
"databaseURL": DATABASE_URL,
23+
"storageBucket": f"{PROJECT_ID}.appspot.com",
24+
}
25+
self.firebase = pyrebase.initialize_app(self.config)
26+
self.auth = self.firebase.auth()
27+
28+
def login(self, email, password):
29+
user = self.auth.sign_in_with_email_and_password(email, password)
30+
return user
31+
32+
def register(self, email, password):
33+
user = self.auth.create_user_with_email_and_password(email, password)
34+
return user
35+
36+
def get_current_user(self):
37+
return self.auth.current_user
38+
39+
def get_user_id(self):
40+
return self.auth.current_user["localId"]
41+
42+
def get_user_email(self):
43+
return self.auth.current_user["email"]
44+
45+
46+
47+
def logout(self):
48+
self.auth.current_user = None
49+
50+
if __name__ == "__main__":
51+
# Instantiate Firebase object
52+
f = Firebase()
53+
54+
# Access and modify data in Realtime Database
55+
print(f.ref.get())
56+
f.ref.set({"name": "Enis Bulut"})
57+
print(f.ref.get())
58+
59+
try:
60+
# Try logging in with existing user credentials
61+
f.login("example@gmail.com", "password")
62+
except Exception as e:
63+
# If login fails, register a new user
64+
f.register("example@gmail.com", "password")
65+
66+
# Get details of current authenticated user
67+
print(f.get_current_user())

Projects/digiRaven/delete.ico

121 KB
Binary file not shown.

Projects/digiRaven/digi.png

1.35 MB
Loading

Projects/digiRaven/download.ico

176 KB
Binary file not shown.
165 KB
Binary file not shown.

0 commit comments

Comments
 (0)