you need a working gpg key, this is to encrypt the gmail.token file
set you gpg key id in the line 47
ENCRYPTION_PIPE = ['gpg', '--encrypt', '--recipient', 'YOUKEYHERE']
Note: Example how to get you key
mkdir ~/.mutt
cd .mutt
curl https://gitlab.com/muttmua/mutt/-/raw/master/contrib/mutt_oauth2.py -o mutt_oauth2.py
chmod +x mutt_oauth2.py
edit mutt_oauth2.py and add the client_id and client_secret (line 61, 62) data from thunderbird app
'client_id': '406964657835-aq8lmia8j95dhl1a2bvharmfk3t1hgqj.apps.googleusercontent.com',
'client_secret': 'kSmqreRr0qwBWJgbf5Y-PjSU',
save the file
execute the follow
./mutt_oauth2.py gmail.token --authorize
and complete:
endpoint: google
oauth flow: localhostauthcode
email: [email protected]
that return an URL, copypaste the URL in a browser and click on "Allow", you need an already logged gmail user
the command will close automatically and write the file "gmail.token" in the folder
to test the token use:
./mutt_oauth2.py oauth2_token_file --test --verbose
you can see something like this:
Access Token: blablabla
IMAP authentication succeeded
POP authentication succeeded
SMTP authentication succeeded
the mutt config must be like this:
set realname = "YOU FULL NAME"
set from = "[email protected]"
set use_from = yes
set envelope_from = yes
set smtp_url = "smtps://[email protected]@smtp.gmail.com:465/"
set imap_user = "[email protected]"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set ssl_force_tls = yes
# G to get mail
bind index G imap-fetch-mail
set editor = "vim"
set charset = "utf-8"
set record = ''
set imap_authenticators = "oauthbearer:xoauth2"
set imap_oauth_refresh_command = "/path/to/.mutt/mutt_oauth2.py /path/to/.mutt/gmail.token"
set smtp_authenticators = ${imap_authenticators}
set smtp_oauth_refresh_command = ${imap_oauth_refresh_command}
run mutt