Topic is created on cloud pub/sub but unable to create watch on that topic

前端 未结 2 800
刺人心
刺人心 2021-01-13 19:13

I want to create watch on cloud pub/sub topic but unable to create it. For that I\'m using the rest request

request_Req.post({

url:\'https://www.googleapis.         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 19:34

    The Google Cloud Pubsub topic must exist in the same Google Console project, which is being used to authenticate the users. Check /projects/ProjectId/topics/TopicId your project in Google Console and make sure the Pubsub Topic exists. Also, you must grant access to Gmail services to publish messages to your Pubsub topic via following request:

    POST "https://pubsub.googleapis.com/v1beta2/{resource=/projects/**ProjectId**/topics/**TopicId**}:setIamPolicy"
    Content-type: application/json
    
    {
      "policy": {
        "bindings": [{
          "role": "roles/pubsub.publisher",
          "members": ["serviceAccount:gmail-api-push@system.gserviceaccount.com"],
        }],
      }
    }
    

    If gmail is not granted the access to publish the message to Pubsub topic, watch request wont be created. Try API explorer to set the permissions.

提交回复
热议问题