Start free
Docs · OAuth app

Developer docs

Quickstart: register an OAuth app on Beplan

Register an OAuth app, send a person through Beplan's consent screen with PKCE, exchange the code for tokens, call the API as that person, refresh, and handle the day they remove your app.

Read as Markdown

On this page
  1. 1. Register the app
  2. 2. Send the person to Beplan
  3. 3. What the person sees
  4. 4. Exchange the code
  5. 5. Call the API
  6. 6. Refresh
  7. 7. When access ends
  8. What to do next
  9. Copy as a prompt

An app is for software other Beplan users connect to their own account. If only you will run it, a personal token is simpler.

1. Register the app

In Beplan, open the organization's settings, then Developer, then New app. You need the right to manage the organization's apps: owners and admins have it by default.

Field What to put
Name, description, logo What people see on the consent screen. Names containing "Beplan" or an assistant's name (Claude, ChatGPT, Cursor…) are refused
Website, privacy policy, terms https:// addresses. A privacy policy is required before the app can be made public
Client type Confidential for a server that can keep a secret. Public for a native or browser app: no secret, PKCE only. It can't be changed later
Redirect addresses Up to five, matched exactly, no wildcards. https:// only, except native apps, which may also use http://localhost, http://127.0.0.1 or http://[::1] on any port, or a reverse-domain scheme (com.example.app:/callback)
Scopes What the app may ask for, and which of those people can't untick. Never all

A confidential app's client secret (beplan_cs_…) is shown once, when the app is created. Store it like a password.

Registering and running an app means following Beplan's developer terms: how to act for people, what you may do with their data, and the security rules.

A new app is private: it works at once, with no warning, for members of your organization, and only reaches your organization. Make it public to let other organizations connect it; until Beplan verifies it, people see a "Not verified by Beplan" warning and at most 25 organizations can connect it (app verification).

2. Send the person to Beplan

Make a PKCE pair for each authorization: a random code_verifier, and its SHA-256 hash, base64url-encoded, as code_challenge. Beplan accepts the S256 method only.

curl
CODE_VERIFIER=$(openssl rand -base64 48 | tr -d '=+/\n' | cut -c1-64)
CODE_CHALLENGE=$(printf '%s' "$CODE_VERIFIER" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')
TypeScript
import { createHash, randomBytes } from "node:crypto";

const codeVerifier = randomBytes(32).toString("base64url");
const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
Python
import base64, hashlib, secrets

code_verifier = secrets.token_urlsafe(32)
code_challenge = base64.urlsafe_b64encode(hashlib.sha256(code_verifier.encode()).digest()).rstrip(b"=").decode()

Then redirect the person's browser to the authorization endpoint:

https://api.beplan.io/api/auth/oauth2/authorize
  ?response_type=code
  &client_id=CLIENT_ID
  &redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
  &scope=organization%3Aread%20posts%3Aread%20posts%3Awrite
  &state=RANDOM_STATE
  &code_challenge=CODE_CHALLENGE
  &code_challenge_method=S256
  • scope: space-separated. A scope your app did not declare is dropped, not refused; if none is left, the request asks for every scope the app declared. offline_access is always added, so every connection gets a refresh token.
  • resource is optional for an app: without it the token is for the API (https://api.beplan.io). Any other value than Beplan's API or MCP server is refused with invalid_target.
  • state: a random value you check when the person comes back.

3. What the person sees

If they are not signed in, Beplan asks them to sign in first (two-factor included), then shows the consent screen:

  • Your app's name, logo and organization, and either Verified or the "Not verified by Beplan" warning.
  • Each scope in plain words, grouped. Sensitive ones are marked, and an unverified public app can't get them (they show as not available). Scopes you marked required can't be unticked; the others can.
  • Where: the organizations it may reach (for a private app, only yours), and in each one all their workspaces or a list they pick. An organization whose policy blocks your app can't be picked; one in Approval mode can, and starts waiting for an admin.

Allow sends the browser back to your redirect address with code and your state (and iss). Deny sends it back with error=access_denied. The code is single-use and lasts 10 minutes.

If the person connected your app before, the screen shows their current choices, and what they pick replaces them.

4. Exchange the code

From your server, post the code to the token endpoint, form-encoded. A confidential app authenticates with HTTP Basic (client_secret_basic); a public app sends only client_id (method none). Secrets in the body (client_secret_post) are refused.

curl
curl -X POST "https://api.beplan.io/api/auth/oauth2/token" \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d grant_type=authorization_code \
  -d code=CODE \
  --data-urlencode redirect_uri=https://app.example.com/callback \
  -d client_id=CLIENT_ID \
  -d code_verifier=CODE_VERIFIER
TypeScript
const response = await fetch("https://api.beplan.io/api/auth/oauth2/token", {
  method: "POST",
  headers: {
    Authorization: `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}`,
    "Content-Type": "application/x-www-form-urlencoded",
  },
  body: new URLSearchParams({
    grant_type: "authorization_code",
    code,
    redirect_uri: "https://app.example.com/callback",
    client_id: clientId,
    code_verifier: codeVerifier,
  }),
});
const tokens = await response.json();
Python
import requests

tokens = requests.post(
    "https://api.beplan.io/api/auth/oauth2/token",
    auth=(client_id, client_secret),
    data={
        "grant_type": "authorization_code",
        "code": code,
        "redirect_uri": "https://app.example.com/callback",
        "client_id": client_id,
        "code_verifier": code_verifier,
    },
).json()

The answer carries access_token (valid one hour), refresh_token, token_type (Bearer), expires_in (seconds), expires_at and scope (the scopes the person kept, plus offline_access). Store the refresh token encrypted; it is the connection.

5. Call the API

Use the access token exactly like a personal token. Call GET /v1/me first: connection.kind is app, scopes are the ones the person kept, and organizations are the ones they picked, each with its state.

curl
curl -X GET "https://api.beplan.io/v1/me" \
  -H "Authorization: Bearer beplan_pat_…"
TypeScript
const response = await fetch("https://api.beplan.io/v1/me", {
  method: "GET",
  headers: {
    Authorization: "Bearer beplan_pat_…",
  },
});
if (!response.ok) throw new Error((await response.json()).error.code);
const { data } = await response.json();
Python
import requests

response = requests.get(
    "https://api.beplan.io/v1/me",
    headers={"Authorization": "Bearer beplan_pat_…"},
)
response.raise_for_status()
data = response.json()["data"]
Answers 200
{
  "data": {
    "user": {
      "id": "user_2x8Kq",
      "name": "Alex Martin"
    },
    "connection": {
      "id": "3c9d1e2f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
      "kind": "personal_token",
      "name": "n8n weekly report",
      "clientId": null,
      "scopes": [
        "profile:read",
        "posts:read",
        "media:read"
      ],
      "expiresAt": "2027-02-17T10:00:00.000Z"
    },
    "organizations": [
      {
        "id": "org_8Hq2LmN4",
        "name": "Studio Halden",
        "state": "active",
        "reason": null,
        "allWorkspaces": true,
        "workspaces": [
          {
            "id": "5d2e8f14-3a6b-4c7d-9e0f-1a2b3c4d5e60",
            "name": "Studio Halden",
            "timezone": "Europe/Paris"
          }
        ]
      }
    ]
  }
}

From there, every operation works as in the API token quickstart, within those scopes and organizations and what the person's role allows.

6. Refresh

Before the access token expires, or when the API answers 401, refresh:

curl -X POST "https://api.beplan.io/api/auth/oauth2/token" \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d grant_type=refresh_token \
  -d refresh_token=REFRESH_TOKEN \
  -d client_id=CLIENT_ID

Each refresh returns a new refresh token: store it and drop the old one. The old one still works for 30 seconds, so a retry after a network error is safe. Used again after that, Beplan treats it as stolen: it ends the whole connection, and the person has to connect your app again. Refresh tokens expire after 90 days.

7. When access ends

Access stops at once, on the next request, when the person removes your app (Integrations in their settings), when an admin of an organization revokes it or blocks your app there, or when the organization turns apps off. What you see:

Situation Answer
The person removed your app, or the connection ended (an old refresh token reused, your own revocation) 401 TOKEN_REVOKED on the API, and refreshing fails with invalid_grant
Beplan suspended your app 401 APP_SUSPENDED on every call
An admin revoked it in one organization, or that organization blocks your app or turned apps off 403 INTEGRATION_BLOCKED_BY_ORGANIZATION with details.reason (revoked_by_admin, client_blocked, door_disabled…), for that organization only
One organization now requires approval 403 INTEGRATION_PENDING_APPROVAL until an admin approves
The person left the organization 404 ORGANIZATION_NOT_FOUND

Listen for connection.revoked and connection.updated on your app webhook to learn about it without waiting for a failed call.

To disconnect from your side (the person signed out of your product, or deleted their account there), revoke the refresh token. That ends the connection, and every access token of it stops:

curl -X POST "https://api.beplan.io/api/auth/oauth2/revoke" \
  -u "CLIENT_ID:CLIENT_SECRET" \
  -d token=REFRESH_TOKEN \
  -d token_type_hint=refresh_token

What to do next

Copy as a prompt

Copy as a prompt
Add "Connect Beplan" to my web app with OAuth 2.1 (authorization code + PKCE S256).

- Authorization endpoint: https://api.beplan.io/api/auth/oauth2/authorize with response_type=code, client_id, redirect_uri (registered exactly), scope (space-separated Beplan scopes, e.g. "organization:read posts:read posts:write"), state (random, checked on return), code_challenge (base64url SHA-256 of a random code_verifier), code_challenge_method=S256.
- The callback receives code and state, or error=access_denied if the person declined.
- Token endpoint: POST https://api.beplan.io/api/auth/oauth2/token, form-encoded, HTTP Basic auth with client_id:client_secret. Exchange: grant_type=authorization_code, code, redirect_uri, client_id, code_verifier. Refresh: grant_type=refresh_token, refresh_token, client_id. Every refresh returns a new refresh token: replace the stored one atomically (the old one works 30 more seconds, then reusing it ends the connection). Access tokens last 1 hour.
- Store refresh tokens encrypted, per user. Never send the client secret to a browser.
- API: base https://api.beplan.io/v1, header "Authorization: Bearer <access token>". Call GET /v1/me after connecting: data.organizations lists the organizations the person gave (state active, pending or blocked) and their workspaces.
- On 401 from the API: refresh once; if refreshing fails (access_denied or invalid_grant), mark the connection as disconnected and ask the person to connect again.
- On 403 INTEGRATION_BLOCKED_BY_ORGANIZATION or INTEGRATION_PENDING_APPROVAL and on 404 for an organization or workspace: show that this organization is unavailable, do not retry.
- Disconnect: POST https://api.beplan.io/api/auth/oauth2/revoke with token=<refresh token>, token_type_hint=refresh_token, HTTP Basic auth.
- Docs: https://beplan.io/docs/quickstart/app.md and https://beplan.io/docs/oauth.md