问题
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?
回答1:
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())
回答2:
const { google } = require('googleapis')
const gmail = google.gmail({ version: 'v1' })
gmail is just an object from the client library. In the above is the node js library. Look in the python client library for answers.
This is what I do not like about a lot of the google docs on their api, they assume you know what is loaded or have seen an example in some obscure place.
来源:https://stackoverflow.com/questions/40057253/watch-request-in-gmail-api-doesnt-work