gmail-oauth2

tool for authenticating to Gmail with OAuth2

WWW CVSWeb GITHub
  1. Package version
    gmail-oauth2-0.20190529p3
  2. Maintainer
    The OpenBSD ports mailing-list

oauth2.py is a script that can be used as a standalone utility for
generating and authorizing OAuth tokens, and for generating OAuth2
authentication strings from OAuth tokens.

This can be used with Mutt to allow oauth2 logins to Gmail, although
in newer version of Mutt (2.0+) an alternative written using Python 3
is available in ${PREFIX}/share/examples/mutt/mutt_oauth2.py.

+-------------------------------------------------------------------------------
| Running ${PKGSTEM} on OpenBSD
+-------------------------------------------------------------------------------

Gmail supports use of RFC 7628 ("OAUTHBEARER") to avoid using
password-based authentication with some mail clients. This package
provides a tool that can perform this authentication.

To use it, you will need to register an application and client ID through the
Google APIs Console, https://console.developers.google.com/apis/credentials
See https://github.com/google/gmail-oauth2-tools/wiki/OAuth2DotPyRunThrough
for more information.

Quick setup guide for Mutt
--------------------------
First, you'll need to register as above and fetch your client id and
secret. Then use them with oauth2.py to generate a token:

oauth2.py --generate_oauth2_token --client_id=[...] --client_secret=[...]

This will display a URL to open. Do this, grant permission, and copy
the code you are given. Paste it into oauth2.py, and you will be given
a "refresh token". Copy this.

Then configure mutt using your client id, secret, and the refresh
token:

set imap_authenticators="oauthbearer"
set imap_user="<email_address>"
set imap_oauth_refresh_command="oauth2.py --quiet --user=USER --client_id=CLIENTID.apps.googleusercontent.com --client_secret=CLIENT_SECRET --refresh_token=REFRESH_TOKEN"

set smtp_authenticators="oauthbearer"
set smtp_url="smtps://USER@gmail.com@smtp.gmail.com:465"
set smtp_oauth_refresh_command="oauth2.py --quiet --user=USER --client_id=CLIENTID.apps.googleusercontent.com --client_secret=CLIENT_SECRET --refresh_token=REFRESH_TOKEN"

  • lang/python/3.10