OAuth2
authorization script for Mutt E-mail client
- Create a Google Cloud project
- Configure OAuth consent screen
- Enable Gmail API
- Create
OAuth
client id
andclient secret
# client id
id="*********************************************.apps.googleusercontent.com"
# client secret
secret="***********************************"
# gpg key id(gpg --list-secret-keys --keyid-format LONG)
keyid="****************"
- Set
id
equal to client id - Set
secret
equal to client secret - Get
gpg
key id
gpg --list-secret-keys --keyid-format LONG
sec rsa4096/{keyid} 2022-06-06 [SC]
- Set
keyid
equal togpg
key id
muttoauth -d
[x] curl
[ ] jq
[x] gpg
[x] shred
muttoauth -a /save/to/tkn_file
Open this URL in a web browser
Copy the authorization code and paste it below
https://accounts.google.com/o/oauth2/auth?client_id=*********************************************.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://mail.google.com/&response_type=code
Authorization Code: *********************************************
set imap_user = "test@gmail.com"
set smtp_url = "smtps://test@gmail.com@smtp.gmail.com:465"
-set my_pass = "`pass show email`"
-set imap_pass = $my_pass
-set smtp_pass = $my_pass
+set imap_authenticators="oauthbearer"
+set imap_oauth_refresh_command = "muttoauth -r /path/to/tkn_file"
+set smtp_authenticators=${imap_authenticators}
+set smtp_oauth_refresh_command=${imap_oauth_refresh_command}