OAuth apps
How it works
- You register an app and send people to the authorization URL.
- They sign in, pick a workspace, review the permissions and choose what happens to posts your app creates.
- Postkea sends them back to your redirect URI with a code, which your app exchanges for an access token and a refresh token.
- 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.
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 -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.
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=S256import { 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 -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{
"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 -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 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.
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.
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 -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:
WWW-Authenticate: Bearer realm="postkea", resource_metadata="https://postkea.com/.well-known/oauth-protected-resource/api/mcp"