diff options
Diffstat (limited to 'worker/imap/configure.go')
-rw-r--r-- | worker/imap/configure.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/worker/imap/configure.go b/worker/imap/configure.go index 691e0d76..a9689f68 100644 --- a/worker/imap/configure.go +++ b/worker/imap/configure.go @@ -38,6 +38,21 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error { w.config.oauthBearer.OAuth2 = oauth2 } + if strings.HasSuffix(w.config.scheme, "+xoauth2") { + w.config.scheme = strings.TrimSuffix(w.config.scheme, "+xoauth2") + w.config.xoauth2.Enabled = true + q := u.Query() + + oauth2 := &oauth2.Config{} + if q.Get("token_endpoint") != "" { + oauth2.ClientID = q.Get("client_id") + oauth2.ClientSecret = q.Get("client_secret") + oauth2.Scopes = []string{q.Get("scope")} + oauth2.Endpoint.TokenURL = q.Get("token_endpoint") + } + w.config.xoauth2.OAuth2 = oauth2 + } + w.config.addr = u.Host if !strings.ContainsRune(w.config.addr, ':') { w.config.addr += ":" + w.config.scheme |