admin管理员组文章数量:1289557
I'm creating an access token with the scope /
. But when authenticating with the gmail SMTP server I get the error eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==
which translates to {"status":"400","schemes":"Bearer","scope":"/"}
. Since I already have that scope in the access token I'm not sure what I'm doing wrong.
Here is my full code:
import base64
import email
import random
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from smtplib import SMTP
import google_auth_oauthlib.flow
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file('credentials.json', ['/'])
creds = flow.run_local_server(port=5000)
print(creds.to_json())
auth_token = '[email protected]\x01token=Bearer ' + creds.token + '\x01\x01'
#print(auth_token.encode('ascii'))
oauth2token = base64.b64encode(auth_token.encode('ascii')).decode('ascii')
with SMTP('smtp.gmail', 587, 'localhost') as smtp:
smtp.set_debuglevel(2)
smtp.starttls()
smtp.ehlo()
smtp.docmd('AUTH XOAUTH2 '+oauth2token)
smtp.noop()
smtp.quit()
I already tried adding more scopes to the access token. The following where tried: openid, .send, .modify, .profile, .email
. Sadly that didn't change a thing. Also tried searching but all I found was people missing the mail.google scope.
本文标签: GMail SMTP XOAUTH2 authentication issueStack Overflow
版权声明:本文标题:GMail SMTP XOAUTH2 authentication issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741480645a2381149.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论