Skip to content

feat: Enable constructing GoogleServiceAccountClient with Credentials.from_service_account_info method #556

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gbretas
Copy link
Contributor

@gbretas gbretas commented Apr 5, 2025

Enable constructing GoogleServiceAccountClient with Credentials.from_service_account_info method

This PR implements the enhancement requested in issue #532.

Changes

  • Added a new from_service_account_info class method to GoogleServiceAccountClient that accepts a service account info dictionary
  • Updated class documentation to reflect the new functionality
  • Added comprehensive unit tests for the new method
  • Created an example file showing how to use this feature

Value

This enhancement allows users to create a GoogleServiceAccountClient using in-memory credentials rather than requiring a file path. This is particularly useful for:

  • Cloud deployments where credentials might be stored in environment variables
  • Containerized applications
  • Applications using secret management tools
  • Any situation where credentials aren't available as files

Usage

# Create client using in-memory credentials
service_account_info = {...}  # Dict containing service account credentials
oauth2_client = oauth2.GoogleServiceAccountClient.from_service_account_info(
    service_account_info, oauth2.GetAPIScope('ad_manager'))

The PR is backward compatible and follows the existing library patterns.

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