GeezerVison is showing github.com — PubSub client example: StatusCode.PERMISSION_DENIED · Issue #697 · GoogleCloudPlatform/python-docs-samples
PubSub client example: StatusCode.PERMISSION_DENIED #697DescriptionIn which file did you encounter the issue?
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/pubsub/cloud-client/publisher.py
Did you change the file? If so, how?
Nope.
Describe the issue
$ python publisher.py list
Traceback (most recent call last):
File "publisher.py", line 93, in <module>
list_topics()
File "publisher.py", line 33, in list_topics
for topic in pubsub_client.list_topics():
File "/usr/local/lib/python2.7/dist-packages/google/cloud/iterator.py", line 210, in _items_iter
for page in self._page_iter(increment=False):
File "/usr/local/lib/python2.7/dist-packages/google/cloud/iterator.py", line 239, in _page_iter
page = self._next_page()
File "/usr/local/lib/python2.7/dist-packages/google/cloud/iterator.py", line 437, in _next_page
items = six.next(self._gax_page_iter)
File "/usr/local/lib/python2.7/dist-packages/google/gax/__init__.py", line 435, in next
return self.__next__()
errors.create_error('RPC failed', cause=exception))
google.gax.errors.GaxError: GaxError(RPC failed, caused by <_Rendezvous of RPC that terminated with (StatusCode.PERMISSION_DENIED, User not authorized to perform this action.)>)
Running the pubsub.projects.topics.list api from https://developers.google.com/apis-explorer workst just fine.
I'm running this inside the Cloud Shell on a project with Cloud Pub/Sub API enabled and some topics set up. gcloud auth list shows my account, cloud auth login greatly discourages me to use it inside a Cloud Shell so I haven't tried refreshing my credentials. Activitytheacodes commented on Dec 5, 2016 @bluecmd there may be something wonky with the cloud shell credentials.
@ryanmats can you take a look? ryanmats commented on Dec 5, 2016 @bluecmd Hi Christian! I just looked at your issue and it looks like you can resolve it by generating a service account key file in JSON (https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount). Once this file is downloaded to your computer, move it to a desired location in the Cloud Shell and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path to the key file, for example:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
This information is in ~/python-docs-samples/pubsub/cloud-client/README.rst
Thanks, and happy holidays! bluecmd commented on Dec 5, 2016 @ryanmats Thanks, but surely that should Just Work(tm) on the cloud shell? "Once that file is downloaded to your computer" doesn't really work that well in Cloud Shell and is quite inconvenient. theacodes commented on Dec 5, 2016 @bluecmd indeed. We're aware of this problem. It's due to a quirk in how cloud shell provides credentials. We've referenced this github issue on the internal bug, and we'll update if there's a resolution. bluecmd commented on Dec 5, 2016 mritchie712 commented on Oct 21, 2017 Any update here? Running into the same issue. csantanaes commented on Jan 9, 2018 theacodes commented on Jan 9, 2018
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|