- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试设置 gmail.users.watch 但收到 403 错误:
向 Cloud PubSub 项目/project-id/topics/topic-id 发送测试消息时出错:用户无权执行此操作。
身份验证正在使用 GOOGLE_APPLICATION_CREDENTIALS
方法和下载的凭据 json 文件进行。
以下代码工作正常,支持我的假设,即身份验证通常有效:
const pubsub = PubSub();
const topic = pubsub.topic('topic-id');
const subscription = pubsub.subscription('subscription-id');
topic.exists()
.then(data => {
console.log(data);
return subscription.exists();
})
.then(data => {
console.log(data);
return subscription.pull()
})
.then(data => {
data[1].receivedMessages.forEach(d => console.log(d));
return topic.publish('Hello, world!');
})
.then(data => {
console.log(data)
})
.catch(err => console.log(err));
该代码没有错误。但是,以下代码会引发上述 403 错误:
const authParams = {
subject: userId,
scopes: [
'https://mail.google.com/',
'https://www.googleapis.com/auth/pubsub'
]
};
gauth.getAuth(authParams)
.then(authClient => {
const params = {
auth: authClient,
userId: 'me',
resource: {
topicName: <topic-id>
}
};
return new Promise((resolve, reject) => {
gmail.users.watch(params, (err, response) => {
if (err) {
console.log(err);
reject(err);
return;
}
resolve(response);
});
});
})
.then(response => {
console.log(response);
});
gauth.getAuth
是 getApplicationDefault
Google Auth Library for Node.js 的简单包装器。 .
G Suite 域安全客户端访问是根据所需范围使用服务帐户的客户端 ID 进行配置的:https://www.googleapis.com/auth/pubsub
,https://mail.google.com/
随着 native 云发布/订阅内容的工作,我认为服务帐户具有在控制台上配置的所有正确权限,因此我对 gmail 调用失败的原因感到有点困惑。
更新:服务帐号在 Google Cloud Console 上拥有以下权限:
项目:(gmail 的东西还需要更多吗?)
主题:
订阅:
进行 Gmail 调用时,服务帐户将委托(delegate)给“主题”。我已将该主体 userId 的权限添加到 Google Cloud Console:
项目:
主题:
订阅:
最佳答案
您需要添加权限,以便可以将消息发布到您的订阅。
转到 Google Cloud 控制台,选择订阅,然后选择权限。在“添加成员”部分中,输入allAuthenticatedUsers,选择Pub/Sub 发布者 Angular 色,然后单击添加
有帮助吗?
更新(2017/05/09):
我正在编辑我的答案,以便更准确地了解所需内容。
根据Gmail API documentation (请参阅授予您主题的发布权部分):
关于javascript - gmail.user.watch 无法使用 DwD 服务帐户向 PubSub 发送测试消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43525182/
对新版本 com.google.cloud.pubsub.spi.v1.Publisher.publish(pubsubMessage).get() 的调用永远挂起。我不确定问题是什么。 代码片段:
根据这里:https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage 当发布者向队列发送消息时,不应填充时间戳字段。所以这
Google PubSub 是否适合小批量(10 条消息/秒)但任务关键型消息传递,保证在任何固定时间段内及时传递每条消息? 或者,它是否更适合高吞吐量,其中个别消息可能偶尔会丢失或无限期延迟? 编辑
我们创建了一个 pull使用 GCP Web GUI 的默认确认截止时间为 10 秒的 PubSub 订阅。原来是我们太乐观了,我们的服务处理一批拉取的消息需要10多秒的时间。该服务不会抛出异常,它实
批处理 pubsub 请求的 NODEJS 示例代码如下所示: // Imports the Google Cloud client library const PubSub = require(`@
在 Google PubSub 中,可以异步调用来自客户端的发布调用。因此,我认为可以同时触发多个发布请求并将其发送到服务器,尤其是在批处理阈值太低的情况下。 如果这是真的,pubsub 客户端如何控
根据堆栈驱动程序图表,我们开始注意到某个主题/订阅的“未确认消息”数量不时增加。 症状 我不知道我们可以信任多少堆栈驱动程序图表,但我已经检查过: 拉取操作数与发布操作数一样多 问题发生时ack操作计
我有一个将数据写入 Google Cloud pubsub 的应用程序,根据 pubsub 的文档,由于重试机制导致的重复是偶尔会发生的事情。还有乱序消息的问题,这在 pubsub 中也不能保证。 另
我有一个包含多个拉取订阅的 pubsub 主题。我想要某种机制,我可以在其中发布带有“优先级”标签的消息,使消息尽可能地跳到队列的前面。 我不需要任何有保证的排序语义,只需要“尽力而为”的优先级机制。
我在我们的平台中集成了 GMB API,并与 PubSub 合作以获取实时评论通知。 为此,我已经完成了以下步骤: Created topic在谷歌 PubSub 云上。 创建了它的 subscrip
试图找出在本地测试 PubSub 推送端点的最佳方法。我们尝试过使用 ngrok.io,但您必须拥有域才能加入白名单(这样做的工具也已损坏……导致无限重定向循环)。我们还尝试在本地模拟 PubSub。
我们希望通过带有 pubsub 触发器 ( https://firebase.google.com/docs/functions/pubsub-events ) 的 firebase 云函数接收有关某
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 2年前关闭。 Improve t
我有一个向 PubSub 主题发布消息的简单服务,偶尔会收到“已超过截止日期”错误消息: GaxError(RPC failed, caused by ) Python代码: from google.
我的应用程序发布少量消息(最多每几秒 1 条)。它不订阅。 首次使用时,PubSub 会创建 60 个永久保持事件状态的线程,如下所示: "grpc-default-worker-ELG-1-1 Id
我想检查运行代码是否有权在特定项目中执行“pubsub.topics.list”。这段代码: try (TopicAdminClient admin = getTopicAdmin()) {
我正在开发微博 spring mvc hibernate 应用程序。我需要实现像推特这样的发布订阅功能。 我正在使用 RabbitMQ 通过 Spring AMQP 抽象进行消息传递。 我在网络上到处
我对 Airflow 很陌生,并尝试使用 apache Airflow 与 google pubsub 的集成,我猜它是添加到“Airflow-300”JIRA 下的。如果我在这里阅读不正确,请纠正我
我正在学习 https://www.woolha.com/tutorials/node-js-google-cloud-pub-sub-basic-examples 上的教程并且有一些困难.. 我在
我在我的 .net 核心微服务中使用 DAPR 和 Docker。我在 docker-compose.yml 中进行了以下配置以运行代理和 dapr pubsub 配置。 PUBSUB.yml api
我是一名优秀的程序员,十分优秀!