Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot filter Gmail API push notifications [duplicate]

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

like image 778
Januka samaranyake Avatar asked Oct 18 '22 23:10

Januka samaranyake


1 Answers

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...

like image 51
PNC Avatar answered Oct 30 '22 03:10

PNC