Gmail OAuth2 configuration
The following instructions can be used to configure a Mail Server that connects to Gmail using OAuth2.
These instructions apply to the Email Document Loader Job as well, although the ports will be different.
1. In Administration - Organisation, create or edit a Mail Server
Enter the following details:
Name | Gmail |
Description | Account settings for Gmail |
Host | smtp.gmail.com |
Port | 587 |
Timeout | 120 |
Connection Security | STARTTLS |
Authentication Method | OAuth2 - Gmail |
2. Click Authorise
The first time this is done, a New OAuth2 Client Registration window will be displayed.
This prompts for the following details:
- Client Id
- Client Secret
These are obtained in the following steps. Note the Redirect URI.
3. Log in to https://console.cloud.google.com
4. Enable the GMail API
ii. Select Enabled API & services
Select Gmail API from the results.
5. App Registration
iii. Click CREATE
- App name: OpenVPMS
- User support email: an email address for users to contact you with questions about their consent
- Under Developer contact information, enter:
- Email addresses: support[at]openvpms[dot]com
vii. In the Updated selected scopes popup, under Manually add scopes, enter:
https://mail.google.com
- https://mail.google.com
- .../auth/userinfo.email
- .../auth/userinfo.profile
- openid
- .../auth/userinfo.email
- .../auth/userinfo.profile
- openid
while Your restricted scopes should display:
6. Test users
iv. Click SAVE AND CONTINUE
7. Credentials
i. Under APIs & Services, select Credentials
ii. Click CREATE CREDENTIALS
iii. Click OAuth client ID
iv. Under Create OAuth client ID, enter
- Application type: Web application
- Name: OpenVPMS
- Authorized redirect URIs: enter the value displayed in the OAuth2 Client Registration e.g. http://localhost:8080/openvpms/oauth2/code/gmail
v. Click CREATE
A popup will display, containing the Client ID and Client Secret:
8. Update OAuth2 Client Registration
Click OK. This should automatically start the Authorise flow. A new browser will be displayed.
After logging in, follow the prompts, and select 'Read, compose, send and permantly delete all your mail from Gmail'
Click Continue.
9. Check Authorisation
In the Mail Server window, click Check Authorisation.
If successful, the Gmail account will appear in the Username field. Click OK.