AI_Agent_Server / backend /credentials.py
Sidreds06's picture
bug fixes
81c40fc
raw
history blame contribute delete
589 Bytes
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")