【问题标题】:Cannot filter Gmail API push notifications [duplicate]无法过滤 Gmail API 推送通知 [重复]
【发布时间】:2017-03-02 11:27:57
【问题描述】:

我试图使用引用 official documentation 的 Google Pub/Sub 将 Gmail inbox event 作为我的应用程序的推送通知。尽管我将labelIds 声明为['INBOX'],但Gmail API 会发送所有事件的通知(即收件箱、已发送、重要等)。我的python代码如下所示,

credentials = get_credentials()
http = credentials.authorize(httplib2.Http()
service = discovery.build('gmail', 'v1', http=http)
request = {
    'labelIds': ['INBOX'],
    'topicName': 'projects/myproject/topics/getNotification'
}
service.users().watch(userId='me',body=request).execute()

如何获取Inbox 事件而不是全部的通知

【问题讨论】:

  • 我想你忘记了labelFilterAction,在写代码之前检查一下这个developers.google.com/apis-explorer/#p/gmail/v1/…检查google api explorer中的方法结构,如果你成功了就写代码。
  • @lok​​esh1729 你能提供labelfilteraction的样本值吗
  • 我从未使用过 Gmail API 我使用过工作表和驱动器,但是如果您转到 Request Body -> Add Property -> Label Filter Action 然后将鼠标悬停在问号上,它们会提供详细信息,如果不尝试使用该短语进行谷歌搜索。

标签: python gmail-api google-cloud-pubsub


【解决方案1】:

上次我调查此问题时,它并没有按记录工作。

我的理解是你应该可以按标签过滤(不是自定义标签)

我的经验是不幸的是我们收到了所有事件的通知...

你可以在这里看到我们的讨论

Gmail API Watch not filtering by Label

我知道 Google 正在努力修复它...

【讨论】:

    猜你喜欢
    • 2018-04-17
    • 2018-10-12
    • 2018-04-12
    • 2020-10-18
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多