-
Notifications
You must be signed in to change notification settings - Fork 13
Fix remaining service account credential wrapping issues #581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+10
−5
Conversation
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
Wrap service account credentials in GoogleCredentialsClient to ensure compatibility with AdManagerClient. The AdManagerClient requires a googleads OAuth2 client wrapper (GoogleOAuth2Client subclass), not raw google.auth credentials. Changes: - Wrap Credentials objects in oauth2.GoogleCredentialsClient before returning from _get_service_account_credentials() - Update tests to verify returned object is GoogleCredentialsClient - Add test to confirm OAuth2 client compatibility with AdManagerClient This fixes 400 errors when calling GAM API with service account auth. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Wrap service account credentials in GoogleCredentialsClient in inventory sync and health check code to fix "CreateHttpHeader" attribute errors. The previous fix only updated src/adapters/gam/auth.py, but there were additional places creating raw Credentials objects and passing them directly to AdManagerClient: 1. src/admin/blueprints/inventory.py (line 571-576): Inventory sync 2. src/adapters/gam/utils/health_check.py (line 82-86): Health checks Both now properly wrap credentials in oauth2.GoogleCredentialsClient before passing to AdManagerClient, consistent with the auth.py fix. Fixes: "Sync failed: GAM error: 'Credentials' object has no attribute 'CreateHttpHeader'" errors when using 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
* Fix GAM service account authentication Wrap service account credentials in GoogleCredentialsClient to ensure compatibility with AdManagerClient. The AdManagerClient requires a googleads OAuth2 client wrapper (GoogleOAuth2Client subclass), not raw google.auth credentials. Changes: - Wrap Credentials objects in oauth2.GoogleCredentialsClient before returning from _get_service_account_credentials() - Update tests to verify returned object is GoogleCredentialsClient - Add test to confirm OAuth2 client compatibility with AdManagerClient This fixes 400 errors when calling GAM API with service account auth. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix remaining service account credential wrapping issues Wrap service account credentials in GoogleCredentialsClient in inventory sync and health check code to fix "CreateHttpHeader" attribute errors. The previous fix only updated src/adapters/gam/auth.py, but there were additional places creating raw Credentials objects and passing them directly to AdManagerClient: 1. src/admin/blueprints/inventory.py (line 571-576): Inventory sync 2. src/adapters/gam/utils/health_check.py (line 82-86): Health checks Both now properly wrap credentials in oauth2.GoogleCredentialsClient before passing to AdManagerClient, consistent with the auth.py fix. Fixes: "Sync failed: GAM error: 'Credentials' object has no attribute 'CreateHttpHeader'" errors when using service account authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- 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
…otocol#581) * Fix GAM service account authentication Wrap service account credentials in GoogleCredentialsClient to ensure compatibility with AdManagerClient. The AdManagerClient requires a googleads OAuth2 client wrapper (GoogleOAuth2Client subclass), not raw google.auth credentials. Changes: - Wrap Credentials objects in oauth2.GoogleCredentialsClient before returning from _get_service_account_credentials() - Update tests to verify returned object is GoogleCredentialsClient - Add test to confirm OAuth2 client compatibility with AdManagerClient This fixes 400 errors when calling GAM API with service account auth. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix remaining service account credential wrapping issues Wrap service account credentials in GoogleCredentialsClient in inventory sync and health check code to fix "CreateHttpHeader" attribute errors. The previous fix only updated src/adapters/gam/auth.py, but there were additional places creating raw Credentials objects and passing them directly to AdManagerClient: 1. src/admin/blueprints/inventory.py (line 571-576): Inventory sync 2. src/adapters/gam/utils/health_check.py (line 82-86): Health checks Both now properly wrap credentials in oauth2.GoogleCredentialsClient before passing to AdManagerClient, consistent with the auth.py fix. Fixes: "Sync failed: GAM error: 'Credentials' object has no attribute 'CreateHttpHeader'" errors when using service account authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- 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
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
CreateHttpHeaderattribute error when using service account authentication by wrapping credentials in all remaining locations.Problem
After PR #579 fixed the auth manager, service account authentication was still failing with:
The previous fix only updated
src/adapters/gam/auth.py, but there were two additional locations creating rawgoogle.oauth2.service_account.Credentialsobjects and passing them directly toAdManagerClient.Root Cause
AdManagerClientrequires agoogleads.oauth2.GoogleOAuth2Clientsubclass (likeGoogleCredentialsClient), not rawgoogle.auth.credentials.Credentialsobjects. The raw credentials don't implement theCreateHttpHeader()method that the googleads library expects.Solution
Wrapped service account credentials in
oauth2.GoogleCredentialsClientin the remaining two locations:src/admin/blueprints/inventory.py(line 571-578): Inventory sync operationssrc/adapters/gam/utils/health_check.py(line 82-89): GAM health checksBoth now follow the same pattern as the auth manager fix:
Changes
File:
src/admin/blueprints/inventory.pyGoogleCredentialsClientfor inventory syncFile:
src/adapters/gam/utils/health_check.pyGoogleCredentialsClientfor health checksTest Results
✅ All 8 service account auth tests pass
✅ All 35 GAM unit tests pass
✅ All 846 unit tests pass
✅ All 174 integration tests pass
Related
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com