Noo88ear commited on
Commit
6fc21ca
·
verified ·
1 Parent(s): 62209f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -13,6 +13,37 @@ from PIL import Image
13
  import io
14
  import base64
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # A2A imports
17
  try:
18
  from a2a_orchestrator import A2AOrchestrator
 
13
  import io
14
  import base64
15
 
16
+ # Google Service Account Authentication Setup
17
+ def setup_google_credentials():
18
+ """Setup Google credentials from service account JSON"""
19
+ try:
20
+ service_account_json = os.getenv("GOOGLE_SERVICE_ACCOUNT_JSON")
21
+ if service_account_json:
22
+ import tempfile
23
+ from google.oauth2 import service_account
24
+
25
+ # Parse the JSON credentials
26
+ credentials_dict = json.loads(service_account_json)
27
+
28
+ # Create credentials from service account info
29
+ credentials = service_account.Credentials.from_service_account_info(credentials_dict)
30
+
31
+ # Set the credentials in environment
32
+ with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
33
+ json.dump(credentials_dict, f)
34
+ os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = f.name
35
+
36
+ print("✅ Google Cloud service account configured")
37
+ return True
38
+ except Exception as e:
39
+ print(f"⚠️ Google Cloud service account setup failed: {e}")
40
+
41
+ print("⚠️ Google Cloud service account not found")
42
+ return False
43
+
44
+ # Setup Google credentials on startup
45
+ setup_google_credentials()
46
+
47
  # A2A imports
48
  try:
49
  from a2a_orchestrator import A2AOrchestrator