Merged
Conversation
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>
This was referenced Oct 24, 2025
EmmaLouise2018
pushed a commit
that referenced
this pull request
Oct 24, 2025
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>
danf-newton
pushed a commit
to Newton-Research-Inc/salesagent
that referenced
this pull request
Nov 24, 2025
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>
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 400 errors when calling GAM API with service account authentication by wrapping credentials in the required
GoogleCredentialsClientwrapper.Problem
AdManagerClientrequires agoogleads.oauth2.GoogleOAuth2Clientsubclass, but the code was passing rawgoogle.oauth2.service_account.Credentialsobjects directly, causing 400 errors with incorrect argument signatures.Solution
google.oauth2.service_account.Credentialsinoauth2.GoogleCredentialsClientbefore returning from_get_service_account_credentials()GoogleCredentialsClientAdManagerClientChanges
File:
src/adapters/gam/auth.pyoauth2.GoogleCredentialsClient()for JSON string pathoauth2.GoogleCredentialsClient()for file pathFile:
tests/unit/test_gam_service_account_auth.pytest_service_account_credentials_creationto verifyGoogleCredentialsClientwrappertest_service_account_returns_compatible_oauth2_clientto verifyGoogleOAuth2ClientinheritanceTest Results
✅ All 8 service account auth tests pass
✅ All 35 GAM unit tests pass
✅ All 846 unit tests pass
✅ All 174 integration tests pass
References
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com