我正在实现一个可以阅读电子邮件的机器人,我正在关注Gmail API
。我可以阅读所有标签,并将其存储在列表中。我不能阅读标签Gmail API python实现
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)
results = service.users().labels().get('me',"INBOX").execute()
print (results.getName())
内部消息,我得到一个错误 -
results = service.users().labels().get('me',"INBOX").execute()
TypeError: method() takes exactly 1 argument (3 given)
官方的API文档实现get label
是在java中。 有人可以告诉我我做错了什么吗?
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly','https://mail.google.com/','https://www.googleapis.com/auth/gmail.modify','https://www.googleapis.com/auth/gmail.labels'
标签和消息是分开的东西。您必须[列出讯息](https://developers.google.com/gmail/api/v1/reference/users/messages/list#examples),然后[让他们](https://developers.google.com/gmail/api/v1/reference/users/messages/get#examples)。 – Tholle
我的范围是否正确申报? – CyberDuck
顺便说一句,官方文档也可以在Python中获得:https://developers.google.com/gmail/api/v1/reference/users/messages/list#python –