User not authorized to perform this action when setting IAM policy

Viewed 5933

I am setting up a topic and trying to grant permission to gmail to send email notification to this topic, but the API call throws "User not authorized to perform this action". I get the same error when I tried from the https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/setIamPolicy. BTW, I started seeing this issue recently. It was working fine before.

POST https://pubsub.googleapis.com/v1/projects/macro-xxxxx-xxx/topics/exxxxx-inxxx:setIamPolicy?key={YOUR_API_KEY}

{
  "policy": {
    "bindings": [
       {
         "role": "roles/pubsub.publisher",
         "members": [
            "serviceAccount:gmail-api-push@system.gserviceaccount.com"
         ]
       }
    ]
  }
}

{
  "error": {
    "code": 403,
    "message": "User not authorized to perform this action.",
    "status": "PERMISSION_DENIED"
   }
}

Appreciate any help, Thanks.

1 Answers

You likely do not have permission to modify the topic in question. You need at least the Pub/Sub Editor or Pub/Sub Admin permission to modify the allowed publishers on a topic. These can be more easily changed in the IAM Console than by the REST API.

Related