Setting up Gmail on aerc

A few days ago, I committed to CMU and got my university email: dennisc2@andrew.cmu.edu. I made an alias, reychen@cmu.edu, and if anyone wants to email my uni email I’d strongly prefer if you emailed that alias because come on, dennisc2 is probably the least sexy email address possible. I mean, why’d they have to put a number in my email?

Anyway, the Gmail web client is a disaster, so I wanted to get my CMU email on aerc. And since CMU uses Google Suites, the problem essentially reduced to getting Gmail to work on aerc.

Tutorial

TL;DR follow the commit message for the aerc patch that introduced aerc support. However, note that the token endpoint — when URL-escaped— is now https%3A%2F%2Foauth2.googleapis.com%2Ftoken instead.

Step-by-step:

Now that you have all the information you need, go to aerc’s accounts.conf and create a new entry with the following source:

source = imaps+oauthbearer://{username}:{refresh_token}@imap.gmail.com:993? \
client_id=XX&\
client_secret=XX&\
token_endpoint=https%3A%2F%2Foauth2.googleapis.com%2Ftoken

The outgoing entry is identical: just replace imaps with smtps and imap.gmail.com:993 with smtp.gmail.com:465 and you’re good to go. Full example:

outgoing = smtps+oauthbearer://{username}:{refresh_token}@smtp.gmail.com:465? \
client_id=XX&\
client_secret=XX&\
token_endpoint=https%3A%2F%2Foauth2.googleapis.com%2Ftoken