Skip to content

Google OAuth2 authorization script for Mutt E-mail client

License

Notifications You must be signed in to change notification settings

murtaza-u/muttoauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

muttoauth2

Google OAuth2 authorization script for Mutt E-mail client

Prerequisite

Edit muttoauth

# 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 to gpg key id

Check for missing dependencies

muttoauth -d

[x] curl
[ ] jq
[x] gpg
[x] shred

Authorize

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: *********************************************

Configure Mutt to use OAuth2

 set imap_user = "[email protected]"
 set smtp_url = "smtps://[email protected]@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}