Spaces:
Sleeping
Sleeping
| import json | |
| import tempfile | |
| import os | |
| def setup_google_credentials(): | |
| creds_json = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON") | |
| if creds_json: | |
| # Create temporary JSON file from environment variable | |
| tmp_path = tempfile.NamedTemporaryFile(delete=False, suffix=".json").name | |
| with open(tmp_path, "w") as f: | |
| f.write(creds_json) | |
| os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = tmp_path | |
| print("[CREDENTIALS] Using Google Cloud credentials from environment") | |
| else: | |
| print("[CREDENTIALS] Using local service account file") | |