问题标签 [google-cloud-pubsub]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1946 浏览

node.js - gcloud pubsub - 如何创建观看请求

我创建了一个主题,订阅它,使用 Google 的 API Explorer 设置主题的发布权限,现在需要创建一个监视请求,如下所述:https ://developers.google.com/gmail/api/guides/推

但是,根据之前的线程,您不能使用 API Explorer 执行此操作,而必须直接从 gcloud 执行此操作。我知道电话的一般形式是这样的:

但是,我不确定如何在 node.js 中实现这一点——代码会是什么样子?我尝试了以下方法,但出现function undefined错误:

非常感谢任何帮助!

0 投票
1 回答
9270 浏览

google-cloud-pubsub - 如何使用 Google Cloud Pub/Sub 进行 Junit 测试

我在我的系统中使用 Google Cloud Pub/Sub 的 push pub/sub,我想构建我的 CI 测试代码,但我不知道该怎么做。例如,一些代码是这样的:

和这个:

如何为这两部分代码编写一个正常的 Junit 测试用例?而且,我正在使用 PowerMockito 来模拟对象。

希望可以有人帮帮我。

0 投票
1 回答
3949 浏览

google-api - Gmail API users.watch - historyId 没有详细信息

我已成功设置 Google Pub/Sub 以使用 Gmail API Watch 功能,如下所述:https ://developers.google.com/gmail/api/guides/push在我的 gmail 帐户中观看收件箱标签。

新消息到达后,我会立即收到有效格式的推送通知,例如:

在我 base64decode 数据后,我收到电子邮件和 historyId。然后,按照建议,我请求 gmail.users.history.list API(通过 API 控制台),并将 startHistoryId 设置为推送通知中的 historyId。然后得到没有任何细节的空响应:

因此,通知中的 historyId 似乎无效。似乎 Gmail users.watch API 无法正常工作,并且发送了错误的 historyId,或者我只是遗漏了一些东西?

0 投票
1 回答
290 浏览

google-app-engine - 由于标签错误,Google PubSub getMessageID = null?

我在从订阅者的 pubsub 消息中获取消息 ID 时遇到了一些困难。问题似乎是 pubsub 消息将 ID 存储在 message_id 字段中,但 getMessageId 方法正在查找不存在的 messageId 字段中的消息 ID。

我正在尝试从另一个应用程序发布的 Pubsub 消息中获取消息 ID。JSON 请求正文如下所示:

我可以使用以下代码成功地重新创建消息:

如果我在调试器中查看消息,它在 message_id 字段中具有有效的消息 ID。但是,getMessageId() 返回 null。如果我使用 setMessageId("SomeKey") 方法,则消息将包含一个带有新值的 messageId 新字段。现在我的消息有两个 ID 字段,message_id 和 messageId。调用 getMessageId 现在返回 messageId 字段值,而不是实际包含在 pubsub 消息中的 message_id。

这是一个错误还是我做错了什么?

0 投票
1 回答
214 浏览

javascript - 是否可以添加一个包含端口的 pushEndpoint?

我正在尝试将 pushEndpoint 添加到我尝试在 Google 的 PubSub ( https://cloud.google.com/pubsub/ ) 中创建的订阅中,以便能够接收来自 Gmail 的推送更新。我要添加的 pushEndpoint 是一个带有端口的 HTTPS-URL(例如:https://developers.example.com:9081/pushEndpoint),但我不断收到Invalid push endpoint given (endpoint=https://developers.briteback.com:9081/mailSyncHandler). Refer to https://cloud.google.com/pubsub/subscriber#create for more information.

所以问题是是否可以将端口添加到 pushEndpoint?

这是尝试创建订阅的代码:

0 投票
1 回答
1616 浏览

javascript - 使用 Google Cloud PubSub 不断收到“向 Cloud PubSub 发送测试消息时出错...”

我正在尝试将 Google 的推送 PubSub 设置到我的服务器以接收 Gmail 推送通知。

我得到以下范围:

它可以创建一个主题,订阅该主题,授予对该主题的 Gmail API 的访问权限,但是当我尝试查看我的收件箱时它失败了。我已遵循本指南:https ://developers.google.com/gmail/api/guides/push ,这是我用来执行上述步骤的代码:

0 投票
1 回答
850 浏览

publish - 设置 GoogleCloudPubsub 消息的过期时间

有没有办法设置我发布的 Google Pubsub 消息(错误请求)的到期时间,以便它不会在失败时无限期重试?

我无法通过重试来配置它,因为我希望有效的错误消息无限期地重试

0 投票
1 回答
245 浏览

google-cloud-dataflow - 如何验证发送到 PubSub 的所有消息是否已正确发送?

我正在运行从 PubSub 读取并写入 BigQuery 的 Dataflow 流式传输管道。当我尝试验证是否所有消息都已写入 BigQuery 时,我意识到有些消息丢失了。

如何验证发送到 PubSub 的所有消息是否已正确发送?

0 投票
1 回答
2284 浏览

oauth-2.0 - How to get userId from access token for Gmail OAuth2.0

What I'm trying to do

I'm trying to create a web app that would fetch emails from a user's Gmail. I understand that I would require authentication via Google OAuth 2.0.

What I'm trying to do is setting a watch() request on an inbox. Then, when the watched inbox gets an email, I want to get notified. I'm using Google's PubSub API.

What I've done

I followed the steps given in the Gmail OAuth documentation, but am confused as to how to store multiple access tokens for multiple users.

So when the user first logs in using their Gmail account, I generate a code which I exchange for an access token. Then I store this in a database. However, when I get notified about an email, I only receive from the API the user's email address. I would like to do some further API calls for this user. So now I would need to retrieve the token for the specific user. But...

The problem

... How do I store access tokens by email? I only have access to their token once they login/authorize. Is there any way of retrieving the email address from an access token? I could then store the access tokens as key-value pairs of <email address>-><access token>.

0 投票
1 回答
1073 浏览

google-app-engine - 来自 App Engine 的 Google Cloud Pubsub 身份验证错误

我们无法将消息发布到 Google AppEngine 上的 Google Cloud PubSub 主题。使用应用程序默认凭据在本地完美运行。但是一旦它部署在 Google AppEngine 上,就会出现以下错误:

我假设它将使用应用引擎的服务帐户来访问 PubSub API。这是我们用来创建凭据的代码。

将实际消息发布到 PubSub 时会引发错误。

并不是说相同的流程可以对“ BigQuery ”进行 API 调用,因此这不是一般的 Google API 问题。它似乎特定于 PubSub ......