gmail API中的观看请求无效

Jan*_*ake 5 python gmail-api google-cloud-pubsub

我正在尝试使用Google API中提到的python发出监视请求,但是它不起作用。

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

我找不到要使用gmail.users()功能的库或包。如何使用访问令牌发出监视请求?

Jan*_*ake 2

在gmail python客户端(由google提供)中执行此操作。在main函数下

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