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

Pubsub: add 'PublisherClient.from_service_account_dict' #8137

Closed
xrmx opened this issue May 24, 2019 · 6 comments · Fixed by #8429
Closed

Pubsub: add 'PublisherClient.from_service_account_dict' #8137

xrmx opened this issue May 24, 2019 · 6 comments · Fixed by #8429
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. auth type: docs Improvement to the documentation for an API.

Comments

@xrmx
Copy link

xrmx commented May 24, 2019

Is your feature request related to a problem? Please describe.
I'd like to use the pubsub client on a webapp where i have the secrets in environment variables and not on disk.
Describe the solution you'd like
I would like to have a classmethod added to Publisher to instantiate a client with the credentials passed from a dict instead of a json file path.

@tseaver tseaver added api: pubsub Issues related to the Pub/Sub API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 24, 2019
@tseaver
Copy link
Contributor

tseaver commented May 24, 2019

@xrmx You should be able to create credentials via the from_service_account_info method, and pass them to the client constructor, e.g.:

from google.oauth2.service_account import Credentials
from google.cloud.pubsub_v1 import PublisherClient

credentials = Credentials.from_service_account_info(your_dict)
publisher_client = PublisherClient(credentials=credentials)

@xrmx
Copy link
Author

xrmx commented May 24, 2019

@tseaver sure I am currently doing this, but it would be nice to have already a wrapper to avoid digging into source code to find out where all this come from :)

@sduskis
Copy link
Contributor

sduskis commented May 27, 2019

I think that this is a general auth problem. There should be a simple way to configure auth. IMHO, if there's a nee for a different auth configuration, there should be a clear and documented way to do more complex configuration. The changes should probably adding more docs for auth, and then getting references to those docs from all of the clients.

@tseaver tseaver changed the title pubsub: Please add Publisher.from_service_account_dict Pubsub: add 'PublisherClient.from_service_account_dict' May 28, 2019
@tseaver tseaver added the auth label May 28, 2019
@tseaver
Copy link
Contributor

tseaver commented May 28, 2019

The PublisherClient API docs should definitely document the args to PublisherClient.__init__ more clearly, including passing a pre-created credentials. Ditto for the SubscriberClient API docs.

Given that we fix the docs, I'd say we don't need to add a from_service_account_dict method to either client.

@tseaver tseaver added type: docs Improvement to the documentation for an API. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 28, 2019
@plamut
Copy link
Contributor

plamut commented Jun 20, 2019

FWIW, there is an open PR that adds a quick example on how to use an other-than-default Credentials object. If that is deemed sufficient, we could close this issue.

Or, if "almost sufficient", the PR can be updated to cover this issue, too.

@xrmx
Copy link
Author

xrmx commented Jun 21, 2019

@plamut commented on the PR, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. auth type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants