googleads-python-lib icon indicating copy to clipboard operation
googleads-python-lib copied to clipboard

feat: Enable constructing GoogleServiceAccountClient with Credentials.from_service_account_info method

Open gbretas opened this issue 9 months ago • 0 comments

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.

gbretas avatar Apr 05 '25 14:04 gbretas