Skip to content

Commit 39a0086

Browse files
committed
Add support for PKCE code challenges; update docs
1 parent 1d181df commit 39a0086

File tree

3 files changed

+74
-18
lines changed

3 files changed

+74
-18
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ Transparently add OAuth 2.0 support to IMAP/POP/SMTP client applications, script
77
<picture>
88
<source width="300" media="(prefers-color-scheme: dark)" srcset="https://auth-email.com/static/img/logo-full-dark.svg">
99
<source width="300" media="(prefers-color-scheme: light)" srcset="https://auth-email.com/static/img/logo-full-light.svg">
10-
<img width="300" src="https://auth-email.com/static/img/logo-full.png" alt="Email-Auth logo">
10+
<img width="300" src="https://auth-email.com/static/img/logo-full.png" alt="Auth-Email.com logo">
1111
</picture><br>
1212
<b>Email OAuth made simple</b><br>
13-
<sub>Auth-Email.com is a unified proxy for all your OAuth 2.0 email accounts.</sub><br>
14-
<sup>Use any app or client to access your accounts with ease.</sup>
13+
<sup>Use any app, client or device to access your OAuth mail accounts with ease.</sup>
1514
</a><br><br>
1615
</div>
1716

1817

1918
## Motivation and capabilities<a id="motivation-and-capabilities"></a>
2019
Email services that support IMAP, POP and/or SMTP access are increasingly requiring the use of OAuth 2.0 to authenticate connections, but not all clients support this method.
21-
This tool creates a local proxy that intercepts the traditional IMAP/POP/SMTP authentication commands and transparently replaces them with the appropriate SASL (X)OAuth 2.0 commands and credentials.
22-
Your email client can continue to use the `login` or `auth`/`authenticate` options, with no need to make it aware of OAuth's existence.
20+
This tool is a local proxy that intercepts the traditional IMAP/POP/SMTP authentication commands and transparently replaces them with the appropriate SASL (X)OAuth 2.0 commands and credentials.
21+
Your email client, app or device can continue to use the `login` or `auth`/`authenticate` options, with no need to make it aware of OAuth's existence.
2322
The proxy works in the background with a menu bar/taskbar helper or as a headless system service, and is compatible with macOS, Windows and Linux.
23+
It can be used with any email provider that supports OAuth 2.0 authentication, including Outlook, Office 365, Hotmail, 21Vianet, Gmail, Google Workspace, Fastmail, Yahoo, Comcast, AOL and many others.
2424

2525
### Example use-cases<a id="example-use-cases"></a>
2626
- You need to use an Office 365 email account, but don't get on with Outlook.
@@ -29,6 +29,7 @@ The email client you like doesn't support OAuth 2.0, which became mandatory [in
2929
- You have an account already set up in an email client, and you need to switch it to OAuth 2.0 authentication.
3030
You can edit the server details, but the client forces you to delete and re-add the account to enable OAuth 2.0, and you don't want to do this.
3131
- You have made your own script or application that sends or receives email, but it doesn't support OAuth 2.0, and you don't want to have to modify it to implement this.
32+
- You use a device or business application that provides functions such as scan to email, email alerts or email to print, but you can't set it up to use the official OAuth 2.0 workarounds from [Microsoft](https://learn.microsoft.com/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-microsoft-365-or-office-365) or [Google](https://support.google.com/a/answer/176600).
3233
- You work with multiple services or applications that use IMAP/POP/SMTP, and you don't want to have to set up OAuth 2.0 independently for each one.
3334

3435
In all of these cases and more, this proxy can help – just follow the instructions below to get started.
@@ -41,7 +42,7 @@ Begin by downloading the proxy via one of the following methods:
4142

4243
<ol type="A">
4344
<li><b>Pick a <a href="https://github.com/simonrob/email-oauth2-proxy/releases/latest">pre-built release</a></b> for your platform (macOS or Windows; no installation needed); <i>or</i>,</li>
44-
<li><b>Install from <a href="https://pypi.org/project/emailproxy/">PyPI</a></b>: set up using <code>python -m pip install emailproxy\[gui\]</code>, download the <a href="https://github.com/simonrob/email-oauth2-proxy/raw/main/emailproxy.config">sample <code>emailproxy.config</code> file</a>, then <code>python -m emailproxy</code> to run; <i>or</i>,</li>
45+
<li><b>Install from <a href="https://pypi.org/project/emailproxy/">PyPI</a></b>: set up using <code>python -m pip install "emailproxy[gui]"</code>, download the <a href="https://github.com/simonrob/email-oauth2-proxy/raw/main/emailproxy.config">sample <code>emailproxy.config</code> file</a>, then <code>python -m emailproxy</code> to run; <i>or</i>,</li>
4546
<li><b>Clone or <a href="https://github.com/simonrob/email-oauth2-proxy/archive/refs/heads/main.zip">download</a></b> (and star :-) the <a href="https://github.com/simonrob/email-oauth2-proxy/">GitHub repository</a>, then: <code>python -m pip install -r requirements-core.txt -r requirements-gui.txt</code> to install requirements, and <code>python emailproxy.py</code> to run.</li>
4647
</ol>
4748

@@ -87,6 +88,7 @@ The [sample configuration file](https://github.com/simonrob/email-oauth2-proxy/b
8788
- Gmail / Google Workspace: register a [Google API desktop app client](https://developers.google.com/identity/protocols/oauth2/native-app).
8889
- Outlook / Hotmail (personal accounts): If you are part of the Microsoft 365 Developer Programme or have an Azure account (including free accounts), you can create your own app registration in the Entra admin centre – see [this discussion](https://github.com/simonrob/email-oauth2-proxy/discussions/301) for a guide.
8990
If not, you will need to reuse an existing client ID – see, for example, [this sample configuration](https://github.com/simonrob/email-oauth2-proxy/issues/297#issuecomment-2424200404).
91+
- Fastmail: register a new [Fastmail OAuth client](https://www.fastmail.com/dev/#registration).
9092
- AOL and Yahoo Mail (and subproviders such as AT&T) are not currently allowing new client registrations with the OAuth email scope – the only option here is to reuse the credentials from an existing client that does have this permission.
9193

9294
The proxy supports [Google Cloud service accounts](https://cloud.google.com/iam/docs/service-account-overview) for access to Google Workspace Gmail.

emailproxy.config

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,11 @@ documentation = Accounts are specified using your email address as the section h
169169
script at https://github.com/simonrob/email-oauth2-proxy/issues/61#issuecomment-1259110336.
170170

171171
- The proxy supports the device authorisation grant (DAG) OAuth 2.0 flow (currently only known to be available for
172-
Office 365 / Outlook), which may better suit headless systems. To use this flow, set `oauth2_flow = device`. With
172+
Office 365 / Outlook), which may better suit headless systems. To use this flow, set `oauth2_flow = device`. With
173173
this flow, the proxy receives authorisation responses directly from the service provider, so no `redirect_uri` is
174174
needed. An example account configuration is given below. For additional customisation, the proxy modifications and
175175
scripts demonstrated at https://github.com/simonrob/email-oauth2-proxy/pull/317 show how the DAG flow authorisation
176-
message could be pushed to a separate device, which may be useful when running the proxy headless or without a GUI.
176+
message could be pushed to a separate device, which may be useful when running the proxy headless or without a GUI.
177177

178178
Gmail customisation:
179179
- The proxy supports the use of service accounts with Gmail for Google Workspace (note: normal Gmail accounts do not
@@ -213,6 +213,9 @@ documentation = Accounts are specified using your email address as the section h
213213
the same address. To avoid clashes, it is recommended that each account has a unique `redirect_uri` (or
214214
`redirect_listen_address`) value, for example by using a different port for each account.
215215

216+
- Some providers require the use of SHA-256 PKCE code challenges instead of client secrets. To use this method, set
217+
`client_secret = pkce` as shown in the Fastmail example below.
218+
216219
Integration with a secrets manager:
217220
- The proxy caches authenticated OAuth 2.0 tokens and associated metadata back into this configuration file by
218221
default, but can alternatively be configured to use either a separate local file (via `--cache-store /path/to/file`)
@@ -241,6 +244,13 @@ redirect_uri = http://localhost
241244
client_id = *** your client id here ***
242245
client_secret = *** your client secret here ***
243246

247+
[your.email@fastmail.com]
248+
permission_url = https://api.fastmail.com/oauth/authorize
249+
token_url = https://api.fastmail.com/oauth/refresh
250+
oauth2_scope = https://www.fastmail.com/dev/protocol-imap https://www.fastmail.com/dev/protocol-pop https://www.fastmail.com/dev/protocol-smtp
251+
client_id = *** your client id here ***
252+
client_secret = pkce
253+
244254
[your.email@yahoo.co.uk]
245255
permission_url = https://api.login.yahoo.com/oauth2/request_auth
246256
token_url = https://api.login.yahoo.com/oauth2/get_token

0 commit comments

Comments
 (0)