Spaces:
Sleeping
Sleeping
| import json | |
| import tempfile | |
| import os | |
| # 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 |