OAuth apps

Let other Postkea users connect your app to their workspace without sharing an API key. Postkea is an OAuth 2.1 authorization server: authorization code with PKCE, rotating refresh tokens, revocation, server metadata and dynamic client registration. Tokens work on the REST API and the MCP server.

How it works

  1. You register an app and send people to the authorization URL.
  2. They sign in, pick a workspace, review the permissions and choose what happens to posts your app creates.
  3. Postkea sends them back to your redirect URI with a code, which your app exchanges for an access token and a refresh token.
  4. Your app calls the API with Authorization: Bearer kea_at_.... It acts like an API key of that workspace, limited to the permissions the person granted and to what their role allows.
EndpointDescription
https://postkea.com/oauth/authorizeAuthorization, the consent screen
https://postkea.com/api/oauth/tokenToken: authorization_code and refresh_token
https://postkea.com/api/oauth/revokeRevocation (RFC 7009)
https://postkea.com/api/oauth/registerDynamic client registration (RFC 7591)
https://postkea.com/.well-known/oauth-authorization-serverAuthorization server metadata (RFC 8414)
https://postkea.com/.well-known/oauth-protected-resource/api/mcpProtected resource metadata (RFC 9728)

Register an app

Create the app in Developers, OAuth apps. Pick Server app when your code runs on a server that can keep a client secret, or Public app for desktop, mobile and browser apps that use PKCE only. Client IDs start with kea_client_ and secrets with kea_secret_; the secret is shown once and you can replace it at any time.

MCP clients register themselves with dynamic client registration (RFC 7591). Up to 20 registrations per hour are accepted from one address:

cURL
curl -X POST https://postkea.com/api/oauth/register \
  -H "Content-Type: application/json" \
  -d '{
    "client_name": "My agent",
    "redirect_uris": ["http://127.0.0.1:33418/callback"],
    "token_endpoint_auth_method": "none",
    "grant_types": ["authorization_code", "refresh_token"]
  }'

Redirect URIs

Codes are only sent to a redirect URI registered for the app, compared character by character. HTTPS is required, except for http://localhost and http://127.0.0.1, where any port matches so apps on a computer can pick a free port. Private schemes of native apps, such as myapp://callback, work too. Fragments are not allowed.

Send people to Postkea

Create a random code_verifier, keep it, and send its SHA-256 as the code_challenge. PKCE with S256 is required for every app. Add a random state and check it when the person comes back.

Authorization URL
https://postkea.com/oauth/authorize
  ?response_type=code
  &client_id=kea_client_...
  &redirect_uri=https://example.com/oauth/callback
  &scope=mcp:read mcp:write
  &state=RANDOM_STATE
  &code_challenge=BASE64URL_SHA256_OF_VERIFIER
  &code_challenge_method=S256
pkce.ts
import { createHash, randomBytes } from "node:crypto";

const verifier = randomBytes(48).toString("base64url");
const challenge = createHash("sha256").update(verifier).digest("base64url");

When the person allows access, Postkea redirects to redirect_uri?code=...&state=...&iss=https://postkea.com. When they cancel, you get error=access_denied. Codes work once and expire after 10 minutes.

Exchange the code

Post the code to the token URL as a form. Server apps also send client_secret, or use HTTP Basic authentication:

cURL
curl -X POST https://postkea.com/api/oauth/token \
  -d grant_type=authorization_code \
  -d code=kea_code_... \
  -d redirect_uri=https://example.com/oauth/callback \
  -d client_id=kea_client_... \
  -d client_secret=kea_secret_... \
  -d code_verifier=YOUR_VERIFIER
200 OK
{
  "access_token": "kea_at_...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "kea_rt_...",
  "scope": "mcp:read mcp:write"
}

Access tokens expire after one hour. Store the refresh token securely.

Refresh tokens

Every refresh returns a new refresh token and invalidates the old one. Always keep the newest. If an old refresh token is used again, Postkea assumes it leaked and disconnects the app; the person has to allow access again.

cURL
curl -X POST https://postkea.com/api/oauth/token \
  -d grant_type=refresh_token \
  -d refresh_token=kea_rt_... \
  -d client_id=kea_client_... \
  -d client_secret=kea_secret_...

You can narrow the scopes on refresh by sending scope, but never widen them.

Call the API

Send the access token as a Bearer token to the REST API or the MCP server:

cURL
curl https://postkea.com/api/v1/posts -H "Authorization: Bearer kea_at_..."

curl -X POST https://postkea.com/api/mcp -H "Authorization: Bearer kea_at_..." \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"whoami","arguments":{}}}'

Requests count against the workspace's credits and rate limit like an API key. Each connection has its own rate limit bucket, its calls appear in the workspace's developer logs under your app's name, and posts it creates follow the posting rule the person picked: publish directly, ask for approval, or drafts only. An app never gets more than the person who connected it: a viewer can only grant read access, and a contributor cannot let an app publish.

A 401 with WWW-Authenticate: Bearer error="invalid_token" means the token expired or was revoked: refresh it, or send the person through the flow again. A 403 with error="insufficient_scope" means the person did not grant that permission.

Scopes

Ask for the scopes you need, separated by spaces. Unknown scopes are ignored; when none are given, mcp:read mcp:write is used. People can untick scopes on the consent screen, so check the scope field of the token response.

NameDescription
mcp:readRead everything in the workspace and look up public social data. Works on REST and MCP.
mcp:writeEverything an API key can do: posts, media, inbox, automations, links. Works on REST and MCP.
posts:readRead posts, the queue and media.
posts:writeCreate, schedule, edit and delete posts.
accounts:readList connected accounts.
accounts:writeConnect and manage accounts.
media:writeUpload, import and transform media.
scrapeRead public social data.
downloadDownload videos and audio.
analytics:readRead analytics and best times.
inbox:readRead comments and messages.
inbox:writeReply to comments and send messages.
aiAI captions and images.
automationsRun and manage automations and monitors.
webhooksManage webhook endpoints.
linksManage short links and bio pages.

Only tokens with mcp:read or mcp:write can open the MCP server.

Revoke tokens

When someone disconnects inside your app, revoke the refresh token. That ends every token of the connection (RFC 7009):

cURL
curl -X POST https://postkea.com/api/oauth/revoke \
  -d token=kea_rt_... \
  -d client_id=kea_client_... \
  -d client_secret=kea_secret_...

People can also disconnect your app in Settings, Connected apps. Access also ends when they leave the workspace or when you delete the app.

Discovery

Clients that support discovery only need the MCP server URL. A request without a token gets a 401 whose WWW-Authenticate header points to the protected resource metadata (RFC 9728), which names Postkea as the authorization server; its metadata (RFC 8414) lists every endpoint:

401 Unauthorized
WWW-Authenticate: Bearer realm="postkea", resource_metadata="https://postkea.com/.well-known/oauth-protected-resource/api/mcp"