Skip to content

Fix service account credential wrapping in GAM setup flow#584

Merged
bokelley merged 1 commit intomainfrom
bokelley/investigate-service-account-issue
Oct 24, 2025
Merged

Fix service account credential wrapping in GAM setup flow#584
bokelley merged 1 commit intomainfrom
bokelley/investigate-service-account-issue

Conversation

@bokelley
Copy link
Collaborator

Summary

Fixes the final location where service account credentials weren't being wrapped, causing CreateHttpHeader errors during GAM tenant setup.

Problem

After PRs #579 and #581 fixed the auth manager, inventory sync, and health checks, service account authentication was still failing during GAM tenant setup (network detection and advertiser/user fetching) with:

'Credentials' object has no attribute 'CreateHttpHeader'

Root Cause

One more location in src/admin/blueprints/gam.py (line 1189-1192) was creating raw google.oauth2.service_account.Credentials and passing them directly to AdManagerClient without wrapping them in GoogleCredentialsClient.

This code is used during the tenant setup flow when:

  • Detecting available GAM networks
  • Fetching advertisers and users for initial configuration

Solution

Wrapped the credentials in oauth2.GoogleCredentialsClient at line 1189-1194:

# Before (WRONG):
oauth2_client = service_account.Credentials.from_service_account_info(...)

# After (CORRECT):
credentials = service_account.Credentials.from_service_account_info(...)
oauth2_client = oauth2.GoogleCredentialsClient(credentials)

Comprehensive Fix Complete

This completes the service account authentication fix across all locations in the codebase:

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

Verification

Searched entire codebase - all instances of service_account.Credentials.from_service_account_* are now properly wrapped in GoogleCredentialsClient before being passed to AdManagerClient.

🤖 Generated with Claude Code

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

Wrap service account credentials in GoogleCredentialsClient in the
GAM setup/network detection flow to fix CreateHttpHeader errors.

Found another location in src/admin/blueprints/gam.py (line 1189-1194)
that was creating raw service_account.Credentials and passing them
directly to AdManagerClient. This is used during:
- Network detection
- Advertiser/user fetching during initial setup

Now properly wraps credentials in oauth2.GoogleCredentialsClient before
passing to AdManagerClient, consistent with all other locations.

Fixes: "'Credentials' object has no attribute 'CreateHttpHeader'"
errors during GAM tenant setup with service account authentication.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 5e00818 into main Oct 24, 2025
8 checks passed
EmmaLouise2018 pushed a commit that referenced this pull request Oct 24, 2025
Wrap service account credentials in GoogleCredentialsClient in the
GAM setup/network detection flow to fix CreateHttpHeader errors.

Found another location in src/admin/blueprints/gam.py (line 1189-1194)
that was creating raw service_account.Credentials and passing them
directly to AdManagerClient. This is used during:
- Network detection
- Advertiser/user fetching during initial setup

Now properly wraps credentials in oauth2.GoogleCredentialsClient before
passing to AdManagerClient, consistent with all other locations.

Fixes: "'Credentials' object has no attribute 'CreateHttpHeader'"
errors during GAM tenant setup with service account 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
Wrap service account credentials in GoogleCredentialsClient in the
GAM setup/network detection flow to fix CreateHttpHeader errors.

Found another location in src/admin/blueprints/gam.py (line 1189-1194)
that was creating raw service_account.Credentials and passing them
directly to AdManagerClient. This is used during:
- Network detection
- Advertiser/user fetching during initial setup

Now properly wraps credentials in oauth2.GoogleCredentialsClient before
passing to AdManagerClient, consistent with all other locations.

Fixes: "'Credentials' object has no attribute 'CreateHttpHeader'"
errors during GAM tenant setup with service account 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.

1 participant