Skip to content
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

Add 'from_service_account_info' classmethod factory to clients. #705

Closed
tseaver opened this issue Dec 10, 2020 · 0 comments · Fixed by #706 or #1133
Closed

Add 'from_service_account_info' classmethod factory to clients. #705

tseaver opened this issue Dec 10, 2020 · 0 comments · Fixed by #706 or #1133
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tseaver
Copy link
Contributor

tseaver commented Dec 10, 2020

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)
@tseaver tseaver added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Dec 10, 2020
@tseaver tseaver self-assigned this Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment