-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_implicit_auth.py
More file actions
37 lines (32 loc) · 1.22 KB
/
Copy pathtest_implicit_auth.py
File metadata and controls
37 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import google.generativeai as genai
import os
import google.auth
print("--- Testing Implicit Auth ---")
# 1. Try genai without config (if it picks up env vars automatically)
try:
print("Attempting list_models without explicit configure...")
for m in genai.list_models():
print(f"Found model: {m.name}")
break
except Exception as e:
print(f"Implicit list_models failed: {e}")
# 2. Try google.auth.default() again with detail
print("\n--- Diagnostic google.auth ---")
try:
creds, project = google.auth.default()
print(f"Creds: {creds}")
print(f"Project: {project}")
if creds:
print("Attempting to configure genai with creds...")
# Note: genai.configure doesn't accept 'credentials' directly in all versions,
# but sometimes it does or we use request_options.
# Actually, standard genai.configure supports 'credentials' arg in newer versions?
# Let's check dir(genai)
pass
except Exception as e:
print(f"google.auth.default() failed: {e}")
# 3. Check for specific Antigravity token env vars
print("\n--- Antigravity Env Check ---")
for k, v in os.environ.items():
if "ANTIGRAVITY" in k:
print(f"{k}={v}")