Cloud Pub/Sub Demo : 403 User not authorized to perform this action. when try to push notification

29,536

Solution 1

Make sure that the client you are using is authorized to publish to Pub/Sub. See details here. If your client belongs to the same project as the topic, typically it won't require additional access control configuration. Make sure that your client is authenticated properly.

Solution 2

Here are some notes come from google's documentation Troubleshooting 403 (Forbidden) error :

If you get this error, do the following:

  • Make sure you've enabled the Google Cloud Pub/Sub API in the Cloud Platform Console.
  • Make sure that the principal making the request has the required permissions on the relevant Google Cloud Pub/Sub resources,
    especially if you are using Google Cloud Pub/Sub for cross-project
    communication.
  • If you're using Dataflow, make sure that both @cloudservices.gserviceaccount.com and the Compute Engine
    Service account [email protected]
    have the required permissions on the relevant Google Cloud Pub/Sub
    resource. See Google Cloud Dataflow Security and Permissions for more information.
  • If you're using App Engine, check your project's Permissions page to see if an App Engine Service Account listed as an Editor. If it is not, add your App Engine Service Account as an Editor. Normally, the App Engine Service Account is of the form
    @appspot.gserviceaccount.com.

Solution 3

In view of subscription and topic you can click "permission" -> "add principal", paste long e-mail from your json with service account and select permissions described in

https://cloud.google.com/pubsub/docs/access-control

enter image description here

Share:
29,536
yusong
Author by

yusong

I am a Master Student at Rice University majoring in Computational Science and Engineering.

Updated on January 20, 2022

Comments

  • yusong
    yusong over 2 years

    I am learning Google Cloud Pub/Sub and following this official document : Writing and Responding to Pub/Sub Messages - Python

    When I deploy it to cloud, and try to submit the message, enter image description here I get the following error :

    An internal error occurred: 403 User not authorized to perform this action. (POST https://pubsub.googleapis.com/v1/projects/your-project-id/topics/your-topic:publish) See logs for full stacktrace.

    I guess it's due to some authentication problem? Any help would be appreciated.

  • Yunnosch
    Yunnosch over 2 years
    Do you intend this to be an answer according to How to Answer In that case it needs some editing. Or is this thanking for or confirming one of the existing answers?
  • Yunnosch
    Yunnosch over 2 years
    Hi Mostafa Farrag. Can I assume that the purpose of this post is to say thanks for an existing answer? It seems so, please confirm or edit to make more obvious what the intention here is.