I was trying to get Gmail inbox event
as a push notification for my application using Google Pub/Sub refering official documentation. Although I declare labelIds
as ['INBOX']
, Gmail API sends notifications for all events (i.e. INBOX, SENT, IMPORTANT & etc). My python Code looks as below,
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()
How can I get it notifications for Inbox
event rather than all
答案 0 :(得分:3)
上次我对此进行了调查,结果没有记录。
我的理解是你应该能够按标签过滤(不是自定义标签)
我的经验是,我们很遗憾地收到了所有活动的通知......
您可以在此处查看我们的讨论
Gmail API Watch not filtering by Label
我知道Google正在努力修复它......