Fix GAM service account authentication #579
Merged
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