createSession()
Create an OAuth session and get the authorization URL.authorize_url in their browser. After they approve, Airstore handles the callback.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
integrationType | IntegrationType | Yes | Provider: gmail, gdrive, github, notion, linear, slack |
workspaceId | string | No | Workspace to attach the connection to. Required for org/admin tokens; optional for workspace tokens (derived from the token). |
returnTo | string | No | URL to redirect to after OAuth completes (same-tab flow). If omitted, a static success/error page is shown. |
Promise<OAuthSession>
| Field | Type | Description |
|---|---|---|
session_id | string | Session ID for polling |
authorize_url | string | URL to redirect the user to |
getSession()
Check the current status of an OAuth session.| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | Session ID from createSession |
Promise<OAuthSessionStatus>
| Field | Type | Description |
|---|---|---|
status | string | pending, complete, or error |
error | string | undefined | Error message if status is error |
connection_id | string | undefined | Connection ID if status is complete |
poll()
Poll a session until it completes, errors, or times out. This is a convenience wrapper aroundgetSession() that checks at a regular interval.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
sessionId | string | Yes | — | Session ID from createSession |
timeout | number | No | 300000 | Max time to wait in ms (5 minutes) |
interval | number | No | 2000 | Polling interval in ms |
Promise<OAuthSessionStatus> — resolves with status: "complete".
Throws
AirstoreErrorif the session status iserror(user denied, provider error, etc.)AirstoreErrorif the timeout is reached before the session completes