首页 > 解决方案 > 在python中使用用户名和密码的Gmail登录API

问题描述

我有usernamegmailpassword帐户,我需要API才能从我的 python 代码自动登录到 gmail。

我试过使用smtplib

import smtplib
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.starttls() 
username="test@gmail.com"
password="test"
server.login(username, password)
server.quit()

我收到smtplib.SMTPAuthenticationError错误

标签: pythondjangogoogle-apigoogle-workspace

解决方案


转到Google 帐户安全设置并登录到您的帐户。

您需要向下滚动并打开“允许不太安全的应用程序”选项。


推荐阅读