我正在与googlegmailapi(python)的一个奇怪问题做斗争。 我正在尝试发送消息,凭据看起来正确(我被重定向到网站接受,如果我允许应用程序管理电子邮件等…)
作用域:'https://mail.google.com/'
代码:
import httplib2
from apiclient import discovery
def SendMessage(user_id, message):
"""Send an email message.
Args:
service: Authorized Gmail API service instance.
user_id: User's email address. The special value "me"
can be used to indicate the authenticated user.
message: Message to be sent.
Returns:
Sent Message.
"""
from GoogleCredentialsMail import get_credentials
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('admin', 'directory_v1', http=http)
message = (service.users().messages().send(userId=user_id,
body=message).execute())
print('Message Id: %s' % message['id'])
return(message)
但我得到一个错误:
^{pr2}$有什么建议吗?在
指向API的链接:https://developers.google.com/gmail/api/guides/sending
当我在管理目录(构建bot以在Google api中移动)时,我习惯于使用:
多亏了伊格尔,我从一开始就开始反思,发现了那个棘手的错误。 我现在开始工作了它看起来:
^{pr2}$相关问题 更多 >
编程相关推荐