Fix service account credential wrapping in GAM setup flow#584
Merged
Conversation
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>
This was referenced Oct 24, 2025
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the final location where service account credentials weren't being wrapped, causing
CreateHttpHeadererrors 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:
Root Cause
One more location in
src/admin/blueprints/gam.py(line 1189-1192) was creating rawgoogle.oauth2.service_account.Credentialsand passing them directly toAdManagerClientwithout wrapping them inGoogleCredentialsClient.This code is used during the tenant setup flow when:
Solution
Wrapped the credentials in
oauth2.GoogleCredentialsClientat line 1189-1194:Comprehensive Fix Complete
This completes the service account authentication fix across all locations in the codebase:
src/adapters/gam/auth.py(auth manager)src/admin/blueprints/inventory.py(inventory sync)src/adapters/gam/utils/health_check.py(health checks)src/admin/blueprints/gam.py(tenant setup)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 inGoogleCredentialsClientbefore being passed toAdManagerClient.🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com