I am following exactly the steps provided here https://cloud.google.com/pubsub/docs/emulator and it is giving me the following error on step number 4 of using the emulator steps.
So when I try to create a topic using googles python libraries as said in the link I get :
File "string", line 3, in raise_from
google.api_core.exceptions.PermissionDenied: 403 User not authorized to perform this action.
status = StatusCode.PERMISSION_DENIED
details = "User not authorized to perform this action."
debug_error_string = "{"created":"@1614133564.919217000","description":"Error received from peer ipv6:[2607:f8b0:4005:807::200a]:443","file":"src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"User not authorized to perform this action.","grpc_status":7}"
Why am I getting such an error if I am trying to work with the local pubsub emulator ?
This should solve it:
export PUBSUB_EMULATOR_HOST=localhost:8085
Why
The command in google tutorial (gcloud beta emulators pubsub env-init
) for some reason doesn't set the environment variable. So your pubsub apis call the service account instead of the local emulator which result in permission errors.
Manually set it and verify it's set using echo $PUBSUB_EMULATOR_HOST