File size: 589 Bytes
81c40fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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")