Skip to content

Conversation

@kmoegling-scope3
Copy link
Contributor

Problem

PR #570 was merged but inventory sync still fails for service account authentication with error:

Sync failed: GAM error: 'Credentials' object has no attribute 'CreateHttpHeader'

Affected tenant: weather at https://sales-agent.scope3.com/admin/tenant/weather/inventory?type=all

Root Cause

The AdManagerClient constructor has different signatures depending on credential type:

  1. OAuth credentials (googleads.oauth2.GoogleRefreshTokenClient):

    • Has CreateHttpHeader method
    • Signature: AdManagerClient(oauth_client, "App Name", network_code=...)
  2. Service account credentials (google.oauth2.service_account.Credentials):

    • Does NOT have CreateHttpHeader method (it's from google-auth, not googleads)
    • Signature: AdManagerClient(credentials, network_code) (2 args only)

Solution

Changed service account AdManagerClient initialization from 3 args to 2 args (line 576):

- client = ad_manager.AdManagerClient(
-     oauth2_credentials, "AdCP Sales Agent", network_code=adapter_config.gam_network_code
- )
+ client = ad_manager.AdManagerClient(oauth2_credentials, adapter_config.gam_network_code)

OAuth path remains unchanged (line 596) - correctly uses 3 arguments.

Evidence

GAM health check (src/adapters/gam/utils/health_check.py:86) uses the same 2-argument pattern:

self.client = ad_manager.AdManagerClient(oauth2_credentials, self.config.get("network_code"))

Testing

  • ✅ Service account auth: Now uses correct 2-arg signature
  • ✅ OAuth auth: Unchanged, continues to use 3-arg signature
  • ✅ Matches established pattern from GAM health check

Impact

  • Fixes inventory sync for service account tenants (e.g., weather)
  • No impact on OAuth tenants (code unchanged)
  • Low risk: One-line change, matches working pattern elsewhere

Fixes #570

PR adcontextprotocol#570 was merged but inventory sync still fails for service account
authentication with error: 'Credentials' object has no attribute 'CreateHttpHeader'

Root Cause:
- google.oauth2.service_account.Credentials lacks CreateHttpHeader method
- AdManagerClient requires 2-arg signature: (credentials, network_code)
- OAuth clients use 3-arg signature: (oauth_client, app_name, network_code=...)

Solution:
- Service account path (line 576): Use 2-argument signature
- OAuth path (line 596): Unchanged, uses 3-argument signature
- Matches GAM health check pattern (src/adapters/gam/utils/health_check.py:86)

Testing:
- Service account tenants: inventory sync now works
- OAuth tenants: unchanged, continues to work

Fixes adcontextprotocol#570
@bokelley bokelley merged commit bcb1686 into adcontextprotocol:main Oct 23, 2025
8 checks passed
EmmaLouise2018 pushed a commit that referenced this pull request Oct 24, 2025
PR #570 was merged but inventory sync still fails for service account
authentication with error: 'Credentials' object has no attribute 'CreateHttpHeader'

Root Cause:
- google.oauth2.service_account.Credentials lacks CreateHttpHeader method
- AdManagerClient requires 2-arg signature: (credentials, network_code)
- OAuth clients use 3-arg signature: (oauth_client, app_name, network_code=...)

Solution:
- Service account path (line 576): Use 2-argument signature
- OAuth path (line 596): Unchanged, uses 3-argument signature
- Matches GAM health check pattern (src/adapters/gam/utils/health_check.py:86)

Testing:
- Service account tenants: inventory sync now works
- OAuth tenants: unchanged, continues to work

Fixes #570
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
…ntextprotocol#571)

PR adcontextprotocol#570 was merged but inventory sync still fails for service account
authentication with error: 'Credentials' object has no attribute 'CreateHttpHeader'

Root Cause:
- google.oauth2.service_account.Credentials lacks CreateHttpHeader method
- AdManagerClient requires 2-arg signature: (credentials, network_code)
- OAuth clients use 3-arg signature: (oauth_client, app_name, network_code=...)

Solution:
- Service account path (line 576): Use 2-argument signature
- OAuth path (line 596): Unchanged, uses 3-argument signature
- Matches GAM health check pattern (src/adapters/gam/utils/health_check.py:86)

Testing:
- Service account tenants: inventory sync now works
- OAuth tenants: unchanged, continues to work

Fixes adcontextprotocol#570
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