Oauth 2.0 脱机IMAP不';在IOS中从AppAuth获取刷新令牌时不同步邮件
我正在尝试使用OfflineImap v7.2.1将我的邮件从gmail同步到本地服务器。我遵循了这个教程:并且让它工作了 这是我的Oauth 2.0 脱机IMAP不';在IOS中从AppAuth获取刷新令牌时不同步邮件,oauth-2.0,imap,gmail-imap,appauth,Oauth 2.0,Imap,Gmail Imap,Appauth,我正在尝试使用OfflineImap v7.2.1将我的邮件从gmail同步到本地服务器。我遵循了这个教程:并且让它工作了 这是我的.offlineimaprc文件: [general] accounts = ExampleCompany [Account ExampleCompany] localrepository = ExampleCompanyLocal remoterepository = ExampleCompanyRemote posts
.offlineimaprc
文件:
[general]
accounts = ExampleCompany
[Account ExampleCompany]
localrepository = ExampleCompanyLocal
remoterepository = ExampleCompanyRemote
postsynchook = notmuch new
#newer versions don't need this
#status_backend = sqlite
[Repository ExampleCompanyRemote]
type = IMAP
remotehost = imap.gmail.com
remoteuser = my-username@gmail.com
ssl = yes
starttls = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
### You'll need to configure the gmail API stuff here:
auth_mechanisms = XOAUTH2
oauth2_client_id = XXXX7-eXXXX.apps.googleusercontent.com
oauth2_client_secret = 9XXXXXP
oauth2_request_url = https://accounts.google.com/o/oauth2/token
#oauth2_refresh_token = 1/ZXXXXXw
oauth2_access_token = ya29.XXXXXIHbcS
## remove Gmail prefix on IMAP folders
nametrans = lambda f: f.replace('[Gmail]/', '') if
f.startswith('[Gmail]/') else f
[Repository ExampleCompanyLocal]
type = Maildir
localfolders = ~/mail
restoreatime = no
# Do not sync this folder
folderfilter = lambda folder: folder not in ['2007-2011-inbox']
## Remove GMAIL prefix on Google-specific IMAP folders that are pulled down.
nametrans = lambda f: '[Gmail]/' + f if f in ['Drafts', 'Starred', 'Important', 'Spam', 'Trash', 'All Mail', 'Sent Mail'] else f
我目前使用谷歌提供的访问令牌和刷新令牌生成我的访问令牌。但是,我希望这个令牌从ios应用程序生成,然后发送到后端开始同步。我正在使用此操作,但OfflineImap在使用从IOS应用程序获取的这些凭据时总是出错。错误
ERROR: All authentication types failed:
XOAUTH2: [AUTHENTICATIONFAILED] Invalid credentials (Failure)
知道为什么这些凭证会无效吗?在运行脚本和应用程序时,我使用的是相同的客户端id
和客户端机密
。我想我遗漏了一些明显的东西
以下是swift中应用程序的授权请求:
// builds authentication request
let request = OIDAuthorizationRequest(configuration: configuration,
clientId: "XXXX7-eXXXX.apps.googleusercontent.com",
clientSecret: "9XXXXXP",
scopes: [OIDScopeEmail],
redirectURL: redirectURI,
responseType: OIDResponseTypeCode,
additionalParameters: nil)
谢谢按照说明运行的脚本要求您生成自己的OAuthClientID和客户端密钥。是的,它不需要。我就是这么做的。它是有效的。问题是当我在应用程序中使用相同的Client_id和Client_secret而不是脚本来生成刷新令牌时。OfflineImap似乎不适用于来自应用程序的刷新令牌