Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/adapters/gam/utils/health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ def _init_client(self) -> bool:
if not key_file:
raise GAMConfigurationError("Missing service_account_key_file in config")

oauth2_credentials = google.oauth2.service_account.Credentials.from_service_account_file(
credentials = google.oauth2.service_account.Credentials.from_service_account_file(
key_file, scopes=["https://www.googleapis.com/auth/dfp"]
)
# Wrap in GoogleCredentialsClient for AdManagerClient compatibility
from googleads import oauth2
oauth2_client = oauth2.GoogleCredentialsClient(credentials)

self.client = ad_manager.AdManagerClient(oauth2_credentials, self.config.get("network_code"))
self.client = ad_manager.AdManagerClient(oauth2_client, "AdCP Health Check", network_code=self.config.get("network_code"))
return True

except Exception as e:
Expand Down
8 changes: 5 additions & 3 deletions src/admin/blueprints/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,15 @@ def sync_inventory(tenant_id):
temp_keyfile = f.name

try:
# Create service account credentials (same pattern as GAM health check)
oauth2_credentials = google.oauth2.service_account.Credentials.from_service_account_file(
# Create service account credentials
credentials = google.oauth2.service_account.Credentials.from_service_account_file(
temp_keyfile, scopes=["https://www.googleapis.com/auth/dfp"]
)
# Wrap in GoogleCredentialsClient for AdManagerClient compatibility
oauth2_client = oauth2.GoogleCredentialsClient(credentials)

# Create GAM client with service account credentials
client = ad_manager.AdManagerClient(oauth2_credentials, adapter_config.gam_network_code)
client = ad_manager.AdManagerClient(oauth2_client, "AdCP Sales Agent", network_code=adapter_config.gam_network_code)
finally:
# Clean up temp file
try:
Expand Down