主题创建在云端发布/订阅上,但无法创建关于该主题的观看 [英] Topic is created on cloud pub/sub but unable to create watch on that topic
问题描述
我想在云端pub / sub主题上创建监视,但无法创建它。为此,我正在使用其余请求
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.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){
});
但是,我收到错误消息将测试消息发送给云$时出错b $ b PubSub / projects / ProjectID / topics / TopicId:Resource not found resource = TopicId
But I'm getting the error message Error sending test message to Cloud
PubSub/projects/ProjectID/topics/TopicId : Resource not found resource=TopicId
推荐答案
Google云Pubsub主题必须位于同一个Google控制台项目中,该项目用于验证用户身份。在Google控制台中检查/项目/ ProjectId / topics / TopicId 项目并确保Pubsub主题存在。此外,您必须授予对Gmail服务的访问权限,才能通过以下请求将消息发布到您的Pubsub主题:
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"],
}],
}
}
如果未授予Gmail将发布消息发布到Pubsub主题的权限,则不会创建观看请求。尝试使用 API资源管理器设置权限。
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.
这篇关于主题创建在云端发布/订阅上,但无法创建关于该主题的观看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!