Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Fixes "Failed to fetch advertisers" error by adding service_account_json support to GoogleAdManagerAdapter's config validation.

Problem

After fixing the credential wrapping issues (PRs #579, #581, #584), service account authentication was still failing when fetching advertisers with:

Failed to fetch advertisers: GAM config requires either 'service_account_key_file' or 'refresh_token'

Root Cause

GoogleAdManagerAdapter.__init__() was only checking for two authentication methods:

  • service_account_key_file (legacy file-based service account)
  • refresh_token (OAuth)

It was not recognizing service_account_json (JSON string-based service account, preferred for cloud deployments), even though:

  • build_gam_config_from_adapter() correctly adds it to config
  • GAMAuthManager correctly handles it
  • GAMClientManager correctly uses it

The adapter was rejecting valid service account configs before they could reach the auth layer.

Solution

Updated GoogleAdManagerAdapter to recognize service_account_json:

Line 90: Store service_account_json from config

self.service_account_json = config.get("service_account_json")

Line 110-111: Update validation to accept all three methods

if not self.key_file and not self.service_account_json and not self.refresh_token:
    raise ValueError("GAM config requires either 'service_account_key_file', 'service_account_json', or 'refresh_token'")

Complete Service Account Fix

This completes the service account authentication implementation:

All service account authentication paths now work end-to-end!

Test Results

✅ All 8 service account auth tests pass
✅ All 35 GAM unit tests pass
✅ All 846 unit tests pass
✅ All 174 integration tests pass

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Fix validation in GoogleAdManagerAdapter to recognize service_account_json
in addition to service_account_key_file and refresh_token.

The adapter was only checking for service_account_key_file (legacy file-based)
and refresh_token (OAuth), but not service_account_json (JSON string-based
service account, preferred for cloud deployments).

This caused "GAM config requires either 'service_account_key_file' or
'refresh_token'" errors when trying to fetch advertisers with service
account authentication using JSON strings.

Changes:
- Line 90: Store service_account_json from config
- Line 110-111: Update validation to accept service_account_json

Fixes: "Failed to fetch advertisers: GAM config requires either
'service_account_key_file' or 'refresh_token'" error when using
service account JSON authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 6090e09 into main Oct 24, 2025
8 checks passed
EmmaLouise2018 pushed a commit that referenced this pull request Oct 24, 2025
…#585)

Fix validation in GoogleAdManagerAdapter to recognize service_account_json
in addition to service_account_key_file and refresh_token.

The adapter was only checking for service_account_key_file (legacy file-based)
and refresh_token (OAuth), but not service_account_json (JSON string-based
service account, preferred for cloud deployments).

This caused "GAM config requires either 'service_account_key_file' or
'refresh_token'" errors when trying to fetch advertisers with service
account authentication using JSON strings.

Changes:
- Line 90: Store service_account_json from config
- Line 110-111: Update validation to accept service_account_json

Fixes: "Failed to fetch advertisers: GAM config requires either
'service_account_key_file' or 'refresh_token'" error when using
service account JSON authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…adcontextprotocol#585)

Fix validation in GoogleAdManagerAdapter to recognize service_account_json
in addition to service_account_key_file and refresh_token.

The adapter was only checking for service_account_key_file (legacy file-based)
and refresh_token (OAuth), but not service_account_json (JSON string-based
service account, preferred for cloud deployments).

This caused "GAM config requires either 'service_account_key_file' or
'refresh_token'" errors when trying to fetch advertisers with service
account authentication using JSON strings.

Changes:
- Line 90: Store service_account_json from config
- Line 110-111: Update validation to accept service_account_json

Fixes: "Failed to fetch advertisers: GAM config requires either
'service_account_key_file' or 'refresh_token'" error when using
service account JSON authentication.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants