Search code examples
pythongmail-apigoogle-cloud-pubsub

Watch request in gmail API doesn't work


I am trying to make a watch request using python as referred to in the google APIs but it does not work.

request = {
  'labelIds': ['INBOX'],
  'topicName': 'projects/myproject/topics/mytopic'
}
gmail.users().watch(userId='me', body=request).execute()

I could not find a library or a package to use gmail.users() function. How do I make a watch request using an access token?


Solution

  • Do it in gmail python client(provide by google).under main function

    request = {
            'labelIds': ['INBOX'],
            'topicName': 'projects/myprojects/topics/getTopic'
        }
        print(service.users().watch(userId='me', body=request).execute())