Wiki
Asphalt OS Try the demo

Connect your company mailbox

The steps a company owner follows to let Asphalt OS read the company mailbox (Google Workspace or Microsoft 365): make an app of your own, copy three values, and paste them on Connections.

The shared inbox reads new email straight out of your company mailbox (office@ and bids@ at your own domain). To let it, the owner of the company makes a small app of your own in Google Cloud (for Google Workspace) or Microsoft Entra (for Microsoft 365), copies three values from it, and pastes them on the Company mailbox card of Connections. It takes about 20 minutes, once. Asphalt OS reads the mailbox, files new email in the shared inbox and changes nothing in the mailbox.

Before you start

  • You need to be an administrator of your Google Workspace or Microsoft 365 account, or have one beside you.
  • Sign in to the browser as the mailbox you want read (for example office@yourcompany.com), not as yourself, for the step that says so.
  • You will copy three values: a Client ID, a Client secret and a Refresh token. Keep the page open in a second tab while you work.
The Client secret and the Refresh token open your mailbox, like a password. Paste them only into the Company mailbox card on Connections. Never email them, text them, put them in a chat or send them to anyone, Asphalt OS support included. The Asphalt OS staff role can help with the rest of the Connections page, but it never needs these two: if anyone asks you for them, even someone who says they are from Asphalt OS, say no. Asphalt OS keeps them encrypted and never shows them again, not even to you.

Google Workspace (Gmail)

  1. Open the Google Cloud console at console.cloud.google.com, signed in as a Workspace administrator, and create a project (any name, such as "Asphalt OS mailbox").
  2. In that project open APIs & Services, then Library, search for Gmail API and press Enable.
  3. Open the OAuth consent screen (Google may call it Google Auth Platform). Give the app a name and your email, and choose the audience Internal: only people in your Workspace can use it, so Google needs no review.
  4. Open Credentials, press Create credentials, then OAuth client ID. Choose the type Web application, and under Authorized redirect URIs add https://developers.google.com/oauthplayground exactly. Press Create. Google shows the Client ID and the Client secret: keep the window open, or paste each into the Company mailbox card now (see Paste them on Connections below).
  5. In a new tab, signed in as the mailbox (office@), open Google's OAuth 2.0 Playground at developers.google.com/oauthplayground. Press the gear at the top right, tick Use your own OAuth credentials, and paste your Client ID and Client secret there.
  6. On the left, in the box under the list, type https://www.googleapis.com/auth/gmail.readonly and press Authorize APIs. Choose the mailbox account and press Allow.
  7. Back on the Playground, press Exchange authorization code for tokens. Copy the long value next to Refresh token.

gmail.readonly lets Asphalt OS read the mailbox and nothing else: it cannot send, delete or move an email.

Microsoft 365 (Outlook)

  1. Open the Microsoft Entra admin center at entra.microsoft.com, signed in as an administrator. Go to App registrations and press New registration. Give it a name (such as "Asphalt OS mailbox"). Under Supported account types choose Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant): Asphalt OS signs in at Microsoft's common address, which Microsoft allows only for this choice (with Accounts in this organizational directory only, step 4 ends on an error page that names AADSTS50194). It lets nobody else into your mailbox: Asphalt OS opens only the mailbox that signs in at step 4, and only with your Client secret. Under Redirect URI choose Web and type http://localhost:8400/ exactly (nothing needs to run there). Press Register. Copy the Application (client) ID shown on the app's page: that is your Client ID.
  2. Open Certificates & secrets, press New client secret, and choose how long it lasts (the longest is easiest; write down when it ends). Copy the Value at once: Microsoft shows it only once. That is your Client secret.
  3. Open API permissions, press Add a permission, Microsoft Graph, Delegated permissions, and tick Mail.Read, User.Read and offline_access. Press Add permissions, then Grant admin consent.
  4. In a new browser tab, signed in as the mailbox (office@), paste this address as one line, with your Client ID in place of YOUR_CLIENT_ID, and press Enter:
    https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=http://localhost:8400/&response_mode=query&scope=offline_access%20Mail.Read%20User.Read
    Accept. The browser then shows an error page: that is expected. Copy the part of its address after code= and before &session_state: that is a one-time code, good for a few minutes.
  5. Microsoft has no page that turns that code into a refresh token, so this step uses PowerShell, which every Windows computer has (press Start, type PowerShell, open it). First paste this line and press Enter:
    $secret = Read-Host 'Client secret' -AsSecureString
    PowerShell asks for the Client secret: paste it (right-click, or Ctrl+V; it shows as stars) and press Enter. Typed at that question, the secret is never part of a command, so PowerShell's list of past commands does not keep it. Then paste this as one line, with your Client ID and the code in place, and press Enter:
    Invoke-RestMethod -Method Post -Uri https://login.microsoftonline.com/common/oauth2/v2.0/token -Body @{ client_id='YOUR_CLIENT_ID'; client_secret=[Net.NetworkCredential]::new('', $secret).Password; code='THE_CODE'; redirect_uri='http://localhost:8400/'; grant_type='authorization_code'; scope='offline_access Mail.Read User.Read' }
    Copy the long value after refresh_token. If it says the code expired, do step 4 again for a fresh code and paste the long line again (the window still holds the secret).

Mail.Read lets Asphalt OS read the mailbox and nothing else: it cannot send, delete or move an email.

Paste them on Connections

  1. In Asphalt OS, as the company owner, open Connections and find the Company mailbox card.
  2. Choose the Mailbox: Google Workspace (Gmail) or Microsoft 365 (Outlook).
  3. Paste the Client ID, the Client secret and the Refresh token, each in its own box, and save each one. Each save asks for your password.
  4. Press Test. The answer says whose mailbox the keys open and how many emails it holds, for example "Google accepted the keys: they open the mailbox office@yourcompany.com (1532 emails). No email was read." The answer can take a few seconds.
  5. Open Settings and press Connect and sync now on the Company mailbox card. New email starts arriving in the shared inbox within two minutes; the first sync reads the last 7 days.

Then close the Google Playground tab or the PowerShell window, and delete any note where you wrote the values down. Closing PowerShell forgets the secret it asked for. If you ever pasted a secret into a PowerShell command itself, delete the file ConsoleHost_history.txt in the folder %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine, where PowerShell keeps the commands typed in it.

A copy of each reply in the Sent folder (optional)

The owner's switch Put a copy of each reply in the mailbox's own Sent folder (the inbox's Rules page) needs one more permission: adding letters to the mailbox. Leave it off if your email already goes out through the same mailbox's own mail server, which keeps its own copy. To grant it on purpose:

  • Google Workspace: do steps 5 to 7 again with two scopes in the box, separated by a space: https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.insert. Paste the new Refresh token on Connections in place of the old one. gmail.insert only adds letters: it cannot send, read more or delete.
  • Microsoft 365: in the app's API permissions add Mail.ReadWrite and press Grant admin consent again; do steps 4 and 5 again with offline_access Mail.Read Mail.ReadWrite User.Read as the scope (in the address write the spaces as %20), and paste the new Refresh token on Connections.

When it stops working

  • Test or the Settings card says the keys were refused: the refresh token was withdrawn (a changed password, the app's access removed, or a Microsoft client secret that ran out). Do the token steps again and paste the new Refresh token; for an expired Microsoft secret, make a new one first and paste it too.
  • To stop Asphalt OS reading the mailbox: press Stop reading the mailbox on Settings, or remove the keys on Connections. To end it for good, also delete the app in Google Cloud or Microsoft Entra.
  • Only the company owner pastes these keys and presses Test: a save by anyone else, Asphalt OS staff included, waits on Connections until the owner approves it. See Testing email and the mailbox.
Esc