hisham-cmd commited on
Commit
707c586
·
verified ·
1 Parent(s): 8066771

Upload set_hf_secrets.py

Browse files
Files changed (1) hide show
  1. set_hf_secrets.py +27 -0
set_hf_secrets.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import HfApi
3
+ from dotenv import load_dotenv
4
+
5
+ load_dotenv()
6
+
7
+ REPO_ID = "hisham-cmd/VortexCommerceBackend"
8
+ HF_TOKEN = os.environ.get("HF_TOKEN")
9
+
10
+ api = HfApi(token=HF_TOKEN)
11
+
12
+ # We need to set these as spaces secrets so the app can read them as environment variables
13
+ secrets = {
14
+ "GOOGLE_CLIENT_ID": os.environ.get("GOOGLE_CLIENT_ID"),
15
+ "GOOGLE_CLIENT_SECRET": os.environ.get("GOOGLE_CLIENT_SECRET"),
16
+ "JWT_SECRET": os.environ.get("JWT_SECRET", "vortex-dev-secret-key-2024-change-in-production")
17
+ }
18
+
19
+ print(f"Setting secrets for {REPO_ID}...")
20
+ for key, value in secrets.items():
21
+ if value:
22
+ api.add_space_secret(repo_id=REPO_ID, key=key, value=value)
23
+ print(f"Added secret {key}")
24
+ else:
25
+ print(f"Warning: Local value for {key} is empty, skipping.")
26
+
27
+ print("Secrets added successfully! Note: You may need to wait a moment or restart the space for them to take effect.")