Unable to filter Gmail API push notifications

I tried to get the Gmail inbox event as a push notification for my application using Google Pub / Sub, citing official documentation . Although I declare labelIds as ['INBOX'] , the Gmail API sends notifications for all events (i.e. INBOX, SENT, IMPORTANT, etc.). My python code looks like 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 notifications for an Inbox event, not all

+5
source share
1 answer

The last time I studied this, it did not work as documented.

I understand that you should be able to filter by label (not a custom label)

My experience was that we received notifications of all events, unfortunately ...

You can see our discussion here.

Gmail API does not filter by label

I know that Google is working to fix it ...

+3
source

Source: https://habr.com/ru/post/1258539/


All Articles