Thread created on cloud pub / sub, but cannot create chat on this thread

I want to create a chat in a cloud pub / smudge but could not create it. For this I use the remainder query

request_Req.post({

url:'https://www.googleapis.com/gmail/v1/users/me/watch',
headers:{
   'content-type': 'application/json',
   'Authorization': 'Bearer '+ access_token,
},
scope : [
    'https://mail.google.com/'
],

'body': JSON.stringify({
    'topicName' : "/projects/ProjectId/topics/TopicId",
    'labelIds' : ["INBOX"] 
});
}),function(error, resp, body){

});

      

But I am getting the error Error sending test message to Cloud PubSub/projects/ProjectID/topics/TopicId : Resource not found resource=TopicId

+3


source to share


2 answers


The Google Cloud Pubsub theme must exist in the same Google Console project that is used to authenticate users. Check / projects / ProjectId / themes / TopicId your project in Google Console and make sure the Pubsub theme exists. In addition, you must provide access to Gmail services to post messages to the Pubsub topic using the 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 did not grant permission to post a message to the Pubsub topic, a view request will not be generated. Try the API to set permissions.

+7


source


Make sure the theme is created and make sure you install it correctly. DO NOT use API Explorer on it as recommended by another answer. Do these calls to Cloud Pub / SUb as the guide says (using the custom service account client): https://developers.google.com/gmail/api/guides/push



+3


source







All Articles