gmail api - Topic is created on cloud pub/sub but unable to create watch on that topic -
i want create watch on cloud pub/sub topic unable create it. i'm using rest request
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'm getting error message error sending test message cloud pubsub/projects/projectid/topics/topicid : resource not found resource=topicid
the google cloud pubsub topic must exist in same google console project, being used authenticate users. check /projects/projectid/topics/topicid project in google console , make sure pubsub topic exists. also, must grant access gmail services publish messages 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 not granted access publish message pubsub topic, watch request wont created. try api explorer set permissions.
Comments
Post a Comment