Spaces:
Sleeping
Sleeping
diegokauer
commited on
Commit
•
14632b5
1
Parent(s):
0db11e8
Create creds.py
Browse files
creds.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import tempfile
|
3 |
+
|
4 |
+
# process of getting credentials
|
5 |
+
def get_credentials():
|
6 |
+
creds_json_str = os.getenv("creds") # get json credentials stored as a string
|
7 |
+
if creds_json_str is None:
|
8 |
+
raise ValueError("GOOGLE_APPLICATION_CREDENTIALS_JSON not found in environment")
|
9 |
+
|
10 |
+
# create a temporary file
|
11 |
+
with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".json") as temp:
|
12 |
+
temp.write(creds_json_str) # write in json format
|
13 |
+
temp_filename = temp.name
|
14 |
+
|
15 |
+
return temp_filename
|