Latest python demo works, but ruby API needed viewer
permission
The python demo shown in episode 3 of Google video series #pubsubmadeeasy
Cloud Pub/Sub in Action worked fine with updated code (see notes below) using the permissions the videos instructed you to add, specifically
Pub/Sub Publisher
Pub/Sub Subscriber
But switching over to the ruby API required adding the viewer permission to the service account created in the demo. Note: using ruby 3.1.0
and gem 'google-cloud-pubsub', '~> 2.9', '>= 2.9.1'
.
Pub/Sub Viewer
Notes on python sample setup:
- Using python 3.10.1
- Sample code
https://github.com/googleapis/python-pubsub.git
specifically
https://github.com/googleapis/python-pubsub/tree/main/samples/snippets/quickstart
virtualenv venv && source venv/bin/activate
pip install --upgrade google-cloud-pubsub
export GOOGLE_APPLICATION_CREDENTIALS=downloaded_key.json
export PROJECT=`gcloud config get-value project`
Error Examples:
subscribe error
/home/dever/.gem/ruby/3.1.0/gems/google-cloud-pubsub-v1-0.6.2/lib/google/cloud/pubsub/v1/subscriber/client.rb:499:
in `rescue in get_subscription':
7:User not authorized to perform this action.. debug_error_string:
{"created":"@1642638738.357361477",
"description":"Error received from peer ipv6:[2607:f8b0:4006:80a::200a]:443",
"file":"src/core/lib/surface/call.cc","file_line":1063,
"grpc_message":"User not authorized to perform this action.","grpc_status":7}
(Google::Cloud::PermissionDeniedError)
publish error
/home/dever/.gem/ruby/3.1.0/gems/google-cloud-pubsub-v1-0.6.2/lib/google/cloud/pubsub/v1/publisher/client.rb:574:
in `rescue in get_topic':
7:User not authorized to perform this action..
debug_error_string:{"created":"@1642638676.763569110",
"description":"Error received from peer ipv6:[2607:f8b0:4006:80a::200a]:443",
"file":"src/core/lib/surface/call.cc","file_line":1063,
"grpc_message":"User not authorized to perform this action.","grpc_status":7}
(Google::Cloud::PermissionDeniedError)