You are not logged in.

#1 2020-07-05 21:36:45

redshoe
Member
Registered: 2015-12-16
Posts: 217

[SOLVED] Authentication failure in mutt. one using OAuth

So, I have four email accounts and one of them uses OAuth authentication (which is personal gmail account). Other accounts just work fine, but when I include this email in muttrc and startup mutt, it gives me authentication failure with the following error message.

OAUTHBEARER authentication failed.

But, if I don't include this particular email in my muttrc and run mutt everything works fine. Is this problem of $folder variable confusion for mutt?

My muttrc file is like the following.

# General options
set header_cache     = "~/.cache/mutt"
set message_cachedir = "~/.cache/mutt"
unset imap_passive
set imap_keepalive   = 300
set mail_check       = 120
set mbox_type        = Maildir
set sort             = reverse-date-received
set editor           = vim
 
# email1
source "~/.mutt/email1"
folder-hook $folder "source ~/.mutt/email1"
 
# email2
source "~/.mutt/email2"
folder-hook $folder "source ~/.mutt/email2"
 
# email3
source "~/.mutt/email3"
folder-hook $folder "source ~/.mutt/email3"
 
# email4
source "~/.mutt/email4"
folder-hook $folder "source ~/.mutt/email4"
 
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/email1<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/email2<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/email3<enter><change-folder>!<enter>'
macro index <f5> '<sync-mailbox><enter-command>source ~/.mutt/email4<enter><change-folder>!<enter>'
  
bind index "G" imap-fetch-mail

Email1,3,4 has the following setting format (they are similar)

# Encrypted password
source "gpg -d ~/.mutt/ps/ps.gpg |"
 
# Receiving options
set imap_user           =  "email134@gmail.com"
set imap_authenticators =  ""
set folder              =  "imaps://email134@gmail.com@imap.gmail.com:993"
set spoolfile           =  "+INBOX"
set postponed           =  "+Drafts"
set record              =  "+Sent"
 
# Sending options
set smtp_url            =  "smtps://email134@gmail.com@smtp.gmail.com:465"
set from                =  "email134@gmail.com"
 
# Connection security settings
set ssl_force_tls       =  yes
 
# Hook
account-hook $folder "set imap_user = email134@gmail.com"

Email2 has the OAuth authentication and its setting is like the following

# Encrypted password
source "gpg -d ~/.mutt/ps/ps.gpg |"
 
# Receiving options
set imap_user                    =  "email2@gmail.com"
set imap_authenticators          =  "oauthbearer"
set imap_oauth_refresh_command   =  "python2 ~/.mutt/oauth2.py --quiet --user=email2@gmail.com --client_id=client_id --client_secret=client_secret --refresh_token=refresh_token"
set smtp_authenticators          =  "oauthbearer"
set smtp_oauth_refresh_command   =  "python2 ~/.mutt/oauth2.py --quiet --user=email2@gmail.com --client_id=client_id --client_secret=client_secret --refresh_token=refresh_token"

set folder                       =  "imaps://email2@gmail.com@imap.gmail.com:993"
set spoolfile                    =  "+INBOX"
set postponed                    =  "+Drafts"
set record                       =  "+Sent"
 
# Sending options
set smtp_url                     =  "smtps://smtp.gmail.com:465"
set from                         =  "email2@gmail.com"
 
# Connection security settings
set ssl_force_tls                =  yes
 
# Hook
account-hook $folder "set imap_user = email2@gmail.com"

Last edited by redshoe (2020-07-05 23:19:21)

Offline

#2 2020-07-05 23:18:45

redshoe
Member
Registered: 2015-12-16
Posts: 217

Re: [SOLVED] Authentication failure in mutt. one using OAuth

Ahh... I think I understood the muttrc wrong. I fixed it somehow.

Here is my muttrc now.

# General options
set header_cache     = "~/.cache/mutt"
set message_cachedir = "~/.cache/mutt"
unset imap_passive
set imap_keepalive   = 300
set mail_check       = 120
set mbox_type        = Maildir
set sort             = reverse-date-received
set editor           = vim
 
# Default account (Stony Brook)
source "~/.mutt/email1"
 
# Folder hooks
folder-hook "email1@gmail.com" "source ~/.mutt/email1"
folder-hook "email2@gmail.com" "source ~/.mutt/email2"
folder-hook "email3@gmail.com" "source ~/.mutt/email3"
folder-hook "email4@gmail.com" "source ~/.mutt/email4"
 
# Macro for switching accounts
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/stonyb<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/wreckd<enter><change-folder>!<enter>'
macro index <f4> '<sync-mailbox><enter-command>source ~/.mutt/bumrin<enter><change-folder>!<enter>'
macro index <f5> '<sync-mailbox><enter-command>source ~/.mutt/umich<enter><change-folder>!<enter>'

bind index "G" imap-fetch-mail

Offline

Board footer

Powered by FluxBB