Skip to content

Commit

Permalink
Use creds json instead of env for firebase
Browse files Browse the repository at this point in the history
  • Loading branch information
yevkim committed Nov 27, 2024
1 parent 8bba198 commit 7de8578
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions backend/functions/fb_manager/firebaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,25 @@ def _initialize_app(self):

if not firebase_admin._apps:
# Replace newlines in private key
private_key = os.getenv("FB_PRIVATE_KEY").replace("\\n", "\n")

cred = credentials.Certificate(
{
"type": os.getenv("FB_TYPE"),
"project_id": os.getenv("FB_PROJECT_ID"),
"private_key_id": os.getenv("FB_PRIVATE_KEY_ID"),
"private_key": private_key, # Use the processed private key
"client_email": os.getenv("FB_CLIENT_EMAIL"),
"client_id": os.getenv("FB_CLIENT_ID"),
"auth_uri": os.getenv("FB_AUTH_URI"),
"token_uri": os.getenv("FB_TOKEN_URI"),
"auth_provider_x509_cert_url": os.getenv("FB_AUTH_PROVIDER_X509_CERT_URL"),
"client_x509_cert_url": os.getenv("FB_CLIENT_X509_CERT_URL"),
"universe_domain": os.getenv("FB_UNIVERSE_DOMAIN"),
}
)
# private_key = os.getenv("FB_PRIVATE_KEY").replace("\\n", "\n")
path_to_creds = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
cred = credentials.Certificate(path_to_creds) # Adjust path as needed

# cred = credentials.Certificate(
# {
# "type": os.getenv("FB_TYPE"),
# "project_id": os.getenv("FB_PROJECT_ID"),
# "private_key_id": os.getenv("FB_PRIVATE_KEY_ID"),
# "private_key": private_key, # Use the processed private key
# "client_email": os.getenv("FB_CLIENT_EMAIL"),
# "client_id": os.getenv("FB_CLIENT_ID"),
# "auth_uri": os.getenv("FB_AUTH_URI"),
# "token_uri": os.getenv("FB_TOKEN_URI"),
# "auth_provider_x509_cert_url": os.getenv("FB_AUTH_PROVIDER_X509_CERT_URL"),
# "client_x509_cert_url": os.getenv("FB_CLIENT_X509_CERT_URL"),
# "universe_domain": os.getenv("FB_UNIVERSE_DOMAIN"),
# }
# )
initialize_app(cred)

self.firestore_client = firestore.client()

0 comments on commit 7de8578

Please sign in to comment.