This page is intentionally non-technical so you can align product, engineering, and design on how Mio behaves before you dive into the Quickstart.
How the integration flows
- Invite the user – your interface launches the OAuth consent screen hosted by Mio. Users review what Mio will read (email + calendar) before approving.
- Confirm the connection – Mio redirects back to your redirect URL with a short-lived authorization code. The browser keeps minimal state.
- Exchange and store – your backend trades the code for durable tokens, encrypts the refresh token, and associates everything with the current account.
- Get Mio Context – whenever you need personalized output, your backend or front-end asks Mio for context and passes it into your own prompts, emails, or experience.
- Refresh in the background – the backend renews tokens on a schedule so users stay connected without repeating OAuth.
OAuth & token lifecycle
- Start the connection – call
connect()(or trigger the hosted button) to send the user into Mio’s consent flow. - Receive the authorization code – Mio sends the browser back to your
redirectUrlwith acodequery parameter. - Call your exchange endpoint – the browser posts that code to your backend (for example
/api/exchange-token). - Swap for tokens – the backend calls
mio.exchangeCodeForTokens(code)and stores the returnedrefreshTokensecurely (encrypted or in a secrets store). - Use short-lived access tokens – pass the
accessTokentogetContextorgetContextSummarywhenever you need Mio Context. - Refresh daily – access tokens expire after 24 hours; schedule calls to
mio.refreshTokens(refreshToken)(or trigger them when you receive a 401) to mint fresh access tokens without asking users to reconnect.
Responsibilities at a glance
Client
Hosts buttons, callbacks, and any immediate feedback to the user. It only keeps short-lived state (e.g., “connected”).
Backend
Stores secrets, exchanges codes, refreshes tokens, and decides how to persist Mio context or trigger downstream jobs.
Mio Context
Receives authenticated requests, turns signals from tools like email and calendar into structured facts, and returns a tailored context object or summary you can plug into any workflow.
Security checkpoints
Protect credentials
Protect credentials
Keep your Mio client secret environment variable in a secret manager and never expose it to the browser.
Require HTTPS
Require HTTPS
Use HTTPS for redirect URLs, token exchange routes, and any endpoint that proxies Mio traffic.
Handle refresh tokens carefully
Handle refresh tokens carefully
Encrypt refresh tokens at rest, rotate them periodically, and keep them server-side so you can request new access tokens without prompting the user again.
Guard your context surface
Guard your context surface
Apply rate limiting or authentication to any proxy endpoint that forwards Mio Context lookups on behalf of thin clients.
Ready to build?
- Read the Quickstart when you are ready to implement the browser → server → Mio Context flow.
- Jump into the API reference for parameters, error codes, and advanced configuration once the basics work.