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
Last time I looked into this it wasn't working as documented.
My understanding is that you should be able to filter by label (not a custom label)
My experience was that we got notifications for all events unfortunately...
You can see our discussion here
Gmail API Watch not filtering by Label
I know was Google working on fixing it...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With