我一直在使用 Google 2 factor auth,并配置了几个应用程序。其中之一是 offlineimap(我下载邮件的地方),但是当我使用 mu4e 撰写邮件时,出现以下错误:
Sending failed: 534-5.7.9 Application-specific password required.
Learn more at 534-5.7.9
http://support.google.com/accounts/bin/answer.py?answer=185833
我有一个 ~/.authinfo.gpg 配置(它手动解密成功),我的 ~/.offlineimaprc 调用 get_password_emacs (我使用的例子可以找到 here )。
我什至试图跳过 gpg 部分以查看它是否有效,直接在 ~/.offlineimaprc 中使用我的 mu4e Google App 密码,但我最终得到了相同的结果。
我的 ~/.authinfo.gpg 文件:(在此处解密,已删除敏感信息)
machine imap.gmail.com login me@gmail.com port 993 password GoogleAppPassword
machine smtp.gmail.com login me@gmail.com port 587 password GoogleAppPassword
我的 ~/.offlineimaprc 文件:
[general]
accounts = Gmail
maxsyncaccounts = 3
pythonfile = ~/.offlineimap.py
[Account Gmail]
localrepository = Local
remoterepository = Remote
[Repository Local]
type = Maildir
localfolders = ~/Maildir
[Repository Remote]
remotehost = imap.gmail.com
remoteuser = me@gmail.com
remotepasseval = get_password_emacs("imap.gmail.com", "me@gmail.com", "993")
ssl = yes
maxconnections = 1
realdelete = no
holdconnectionopen = true
keepalive = 60
type = IMAP
和我的 ~/.offlineimap.py
#!/usr/bin/python
import re, os
def get_password_emacs(machine, login, port):
s = "machine %s login %s port %s password ([^ ]*)\n" % (machine, login, port)
p = re.compile(s)
authinfo = os.popen("gpg -q --no-tty -d ~/.authinfo.gpg").read()
return p.search(authinfo).group(1)
任何人都可以看到我遇到的问题吗?我已经验证 ~/.authinfo.gpg 文件解密成功,并且我的 Google App 密码正确。
谢谢你的时间。
最佳答案
using my mu4e Google App Password directly in the ~/.offlineimaprc
这正是问题所在。您不应该直接使用密码。对于不接受第二因素 token 的旧应用程序,您需要改用应用程序特定的密码。这是您从此 URL 生成的密码:
https://security.google.com/settings/security/apppasswords
并且您使用生成的密码代替您的真实密码。但是,您应该注意,这些特定于应用程序的密码授予对您帐户的完全访问权限。因此,使用应用密码会显着降低您在帐户上启用 2-factor 所获得的保护。
关于emacs - 在 mu4e 和 Gmail 中使用 Google 两因素身份验证时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26112386/