我正在尝试使用 Exchange 365 电子邮件帐户设置 Mutt 终端电子邮件客户端。我使用它是mutt_oauth.py
为了促进 OAuth 流程。
我已按照中的说明进行操作自述文件但我遇到了一个问题。当我加载 mutt 时,它尝试登录但返回以下错误:
mutt_account_getoauthbearer: Command returned empty string
这是输出mutt -d 5
:
[2022-10-19 13:49:59] Mutt/2.2.7 (2022-08-07) debugging at level 5
[2022-10-19 13:49:59] In mutt_reflow_windows
[2022-10-19 13:49:59] In mutt_reflow_windows
[2022-10-19 13:49:59] In mutt_reflow_windows
[2022-10-19 13:49:59] In mutt_reflow_windows
[2022-10-19 13:49:59] Reading configuration file '/opt/homebrew/Cellar/mutt/2.2.7/etc/Muttrc'.
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047c9e90, *ldata = 0x0
[2022-10-19 13:49:59] parse_attach_list: added */.* [9]
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047c9ea0, *ldata = 0x0
[2022-10-19 13:49:59] parse_attach_list: added text/x-vcard [7]
[2022-10-19 13:49:59] parse_attach_list: added application/pgp.* [2]
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047c9ea0, *ldata = 0x600001d588d0
[2022-10-19 13:49:59] parse_attach_list: skipping text/x-vcard
[2022-10-19 13:49:59] parse_attach_list: skipping application/pgp.*
[2022-10-19 13:49:59] parse_attach_list: added application/x-pkcs7-.* [2]
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047ca300, *ldata = 0x0
[2022-10-19 13:49:59] parse_attach_list: added text/plain [7]
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047c9ea0, *ldata = 0x600001d588d0
[2022-10-19 13:49:59] parse_attach_list: skipping text/x-vcard
[2022-10-19 13:49:59] parse_attach_list: skipping application/pgp.*
[2022-10-19 13:49:59] parse_attach_list: skipping application/x-pkcs7-.*
[2022-10-19 13:49:59] parse_attach_list: added message/external-body [4]
[2022-10-19 13:49:59] parse_attach_list: ldata = 0x1047ca308, *ldata = 0x0
[2022-10-19 13:49:59] parse_attach_list: added message/external-body [4]
[2022-10-19 13:49:59] Reading configuration file '/Users/jlcarveth/.mutt/muttrc'.
[2022-10-19 13:49:59] Using default IMAP port 143
[2022-10-19 13:49:59] Using default IMAPS port 993
[2022-10-19 13:49:59] Setting $hostname
[2022-10-19 13:49:59] getdnsdomainname(): localdomain
[2022-10-19 13:49:59] $hostname set to "JLCM2.localdomain"
[2022-10-19 13:49:59] Reading imap://outlook.office365.com/INBOX...
[2022-10-19 13:49:59] Looking up outlook.office365.com...
[2022-10-19 13:49:59] Connecting to outlook.office365.com...
[2022-10-19 13:49:59] Connected to outlook.office365.com:143 on fd=7
[2022-10-19 13:49:59] imap_cmd_step: grew buffer to 512 bytes
[2022-10-19 13:49:59] 7< * OK The Microsoft Exchange IMAP4 service is ready. [***OMITTED***]
[2022-10-19 13:49:59] IMAP queue drained
[2022-10-19 13:49:59] 7> a0000 CAPABILITY
[2022-10-19 13:49:59] 7< * CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
[2022-10-19 13:49:59] Handling CAPABILITY
[2022-10-19 13:49:59] 7< a0000 OK CAPABILITY completed.
[2022-10-19 13:49:59] IMAP queue drained
[2022-10-19 13:49:59] 7> a0001 STARTTLS
[2022-10-19 13:49:59] 7< a0001 OK Begin TLS negotiation now.
[2022-10-19 13:49:59] IMAP queue drained
[2022-10-19 13:49:59] ssl_load_certificates: loading trusted certificates
[2022-10-19 13:49:59] mutt_ssl_starttls: Error loading trusted certificates
[2022-10-19 13:49:59] ssl_verify_callback: checking cert chain entry /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root CA (preverify: 1 skipmode: 0)
[2022-10-19 13:49:59] ssl_verify_callback: checking cert chain entry /C=US/O=DigiCert Inc/CN=DigiCert Cloud Services CA-1 (preverify: 1 skipmode: 0)
[2022-10-19 13:49:59] ssl_verify_callback: checking cert chain entry /C=US/ST=Washington/L=Redmond/O=Microsoft Corporation/CN=outlook.com (preverify: 1 skipmode: 0)
[2022-10-19 13:49:59] ssl_verify_callback: hostname check passed
[2022-10-19 13:49:59] TLSv1.2 connection using TLSv1.2 (ECDHE-RSA-AES256-GCM-SHA384)
[2022-10-19 13:50:00] 7> a0002 CAPABILITY
[2022-10-19 13:50:00] 7< * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
[2022-10-19 13:50:00] Handling CAPABILITY
[2022-10-19 13:50:00] 7< a0002 OK CAPABILITY completed.
[2022-10-19 13:50:00] IMAP queue drained
[2022-10-19 13:50:00] imap_authenticate: Trying method oauthbearer
[2022-10-19 13:50:00] SASL local ip: 192.168.1.248;55042, remote ip:52.96.88.162;143
[2022-10-19 13:50:00] External SSF: 256
[2022-10-19 13:50:00] mutt_sasl_cb_authname: getting user for outlook.office365.com:143
[2022-10-19 13:50:00] imap_auth_sasl: oauthbearer unavailable
[2022-10-19 13:50:00] imap_authenticate: Trying method xoauth2
[2022-10-19 13:50:00] Authenticating (XOAUTH2)...
[2022-10-19 13:50:00] mutt_account_getoauthbearer: Command returned empty string
[2022-10-19 13:50:02] mutt_index_menu[827]: Got op 99
[2022-10-19 13:50:02] q: unknown command
[2022-10-19 13:50:03] mutt_index_menu[827]: Got op 177
[2022-10-19 13:50:03] Closing connection to outlook.office365.com...
[2022-10-19 13:50:03] 7> a0003 LOGOUT
[2022-10-19 13:50:03] 7< * BYE Microsoft Exchange Server IMAP4 server signing off.
[2022-10-19 13:50:03] Handling BYE
[2022-10-19 13:50:03] 7< a0003 OK LOGOUT completed.
[2022-10-19 13:50:03] IMAP queue drained
[2022-10-19 13:50:03] mutt_buffer_pool_free: 10 of 10 returned to pool
我不确定如何解决此错误。当我运行时,我的令牌似乎有效,因为令牌已打印并且没有问题。python3 mutt_oauth.py [email protected] --verbose --test
我的~/.mutt/muttrc
很简单:
set imap_user="***OMITTED***"
set folder="imap://outlook.office365.com/"
#set imap_pass='***OMITTED***'
set smtp_url = "smtp://${imap_user}@smtp.office365.com:587/"
set imap_authenticators="oauthbearer:xoauth2"
set imap_oauth_refresh_command="/Users/jlcarveth/mutt_oauth.py \
--quiet ${imap_user}.tokens"
set smtp_authenticators='${imap_authenticators}'
set smtp_oauth_refresh_command=${imap_oauth_refresh_command}
set spoolfile=+INBOX
# Store message headers locally to speed things up
set header_cache=~/.cache/mutt
set message_cachedir=~/.cache/mutt
# Allow mutt to open an IMAP connection passively
unset imap_passive
set imap_keepalive = 300
杂种狗 v 2.2.7
答案1
这条线在这里
set imap_oauth_refresh_command="/Users/jlcarveth/mutt_oauth.py \
--quiet ${imap_user}.tokens"
${imap_user}.tokens
不是绝对路径。我的猜测是这是你的问题。尝试在此处添加令牌文件的完整路径。
答案2
Mutt 的mutt_account_getoauthbearer
方法尝试使用您定义的任何内容imap_oauth_refresh_command
来获取/刷新令牌。Command returned empty string
意味着由于某种原因对外部脚本的调用失败。一些可能的原因:
外部刷新命令的路径不正确。 (您指定了
mutt_oauth.py
。您的意思是mutt_oauth2.py
,还是您重命名了脚本?)路径
${imap_user}.tokens
不正确。 (正如 @mokchira 指出的那样,它需要是令牌存储的完整路径。)您的密钥受密码保护,但
gpg-agent
无法提示输入密码,因为GPG_TTY
没有为您的 shell 正确设置环境变量。
如果/path/to/mutt_oauth.py /path/to/${imap_user}.tokens
在 shell 中运行返回一个身份验证令牌,但您在 Mutt 中仍然收到错误,请查看GPG_TTY
.您可以通过暂时从 GPG 密钥中删除密码来隔离此处的问题。