diegokauer's picture
Create creds.py
14632b5
raw
history blame
523 Bytes
import json
import tempfile
# process of getting credentials
def get_credentials():
creds_json_str = os.getenv("creds") # get json credentials stored as a string
if creds_json_str is None:
raise ValueError("GOOGLE_APPLICATION_CREDENTIALS_JSON not found in environment")
# create a temporary file
with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".json") as temp:
temp.write(creds_json_str) # write in json format
temp_filename = temp.name
return temp_filename