Connecting Gmail and Outlook mailboxes on your server
Applies to: the IT Admin User (one-time registration) and Workspace Admins ยท Time: about 20 minutes
Overview
This is optional. Invitations and notifications already go out through your company mail server. Connecting Gmail or Outlook lets each person read and send their own email inside Digital Workspace, and sync their calendar.
On your own server, Continue with Gmail and Continue with Outlook work only after your IT Admin User registers an app with Google or Microsoft for your server. Until then, clicking one of them shows Gmail sign-in isn't enabled on this server yet (or Outlook), and people can still use the simple in-app inbox.
Before you begin
- HTTPS is turned on with a server name (see "Turning on HTTPS"). Google and Microsoft accept only https:// return addresses. Google also needs a real domain name, not an IP address.
- The Web address in Workspace settings โบ Mail server is the HTTPS address.
- The Email Inbox module is turned on in Workspace settings โบ Modules.
- The server can reach Google (accounts.google.com, googleapis.com) or Microsoft (login.microsoftonline.com, graph.microsoft.com) on the internet. An offline server can't connect these mailboxes.
Your return address (redirect URI)
Both registrations need this address. Replace the first part with your web address:
https://workspace.company.uz/api/email/oauth/callback
Outlook / Microsoft 365 (IT Admin User)
- In the Microsoft Entra admin center, open App registrations โ New registration.
- Name it Digital Workspace. Under Supported account types, keep Accounts in this organizational directory only. Under Redirect URI, choose Web and paste your return address. Click Register.
- Copy the Application (client) ID and the Directory (tenant) ID.
- Open Certificates & secrets โ New client secret and copy its Value.
- Open API permissions โ Add a permission โ Microsoft Graph โ Delegated, and add openid, email, profile, offline_access, User.Read, Mail.Read, Mail.Send and Calendars.ReadWrite. Click Grant admin consent.
Gmail / Google Workspace (IT Admin User)
- In the Google Cloud console, create a project and enable the Gmail API (and the Google Calendar API for calendars).
- Set up the OAuth consent screen. For a company Google Workspace, choose Internal so that only your colleagues can use it.
- Open Credentials โ Create credentials โ OAuth client ID, type Web application, and add your return address under Authorized redirect URIs.
- Copy the Client ID and Client secret.
Add the keys to the server (IT Admin User)
- On the server, open /opt/digital-workspace/.env. Find the lines you need, remove the # at the start of each one, and fill in the value after the = sign:
MICROSOFT_CLIENT_ID=,MICROSOFT_CLIENT_SECRET=andMICROSOFT_TENANT=(your Directory (tenant) ID)GOOGLE_CLIENT_ID=andGOOGLE_CLIENT_SECRET=
- Apply the change:
cd /opt/digital-workspace && sudo docker compose up -d app. - Keep the client secrets private. Never paste them in chat or email; Microsoft secrets expire, so note the date and replace the secret before it does.
Connect a mailbox
- Each person opens Email Inbox and clicks Continue with Gmail or Continue with Outlook.
- They sign in on the Google or Microsoft page and approve access, then return to Digital Workspace.
The rest works as described in "Setting Up Email". Invitations still go out through the company mail server.
Troubleshooting
| Message | Resolution |
|---|---|
| Gmail (or Outlook) sign-in isn't enabled on this server yet | The keys are missing from .env, the lines still start with #, or the app wasn't restarted with docker compose up -d app. |
| Google or Microsoft says the redirect URI doesn't match | The return address registered must match the Web address exactly, including https:// and with no slash at the end. |
| Outlook work account says "Need admin approval" | Grant admin consent for the app in Entra (API permissions). |
| Company Gmail says "blocked by your admin" | Your Google Workspace admin marks the app as trusted in the Admin console (Security โบ API controls). |
These articles are also in the Knowledge Base on your own server, after it is updated.