Skip to content

Add 'from_service_account_info' classmethod factory to clients. #705

@tseaver

Description

@tseaver

Follow-on to #244.

See discussion in googleapis/python-cloud-core#8

The rationale is that some users prefer not to store service account credentials on the filesystem, but instead pass them in via e.g. the environment.

    @classmethod
    def from_service_account_file(cls, info: dict, *args, **kwargs):
        """Creates an instance of this client using the provided credentials info.

        Args:
            info (dict): The service account private key info.
            args: Additional arguments to pass to the constructor.
            kwargs: Additional arguments to pass to the constructor.

        Returns:
            {@api.name}: The constructed client.
        """
        credentials = service_account.Credentials.from_service_account_info(info)
        kwargs["credentials"] = credentials
        return cls(*args, **kwargs)

Metadata

Metadata

Assignees

Labels

type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions