Skip to main content
OAuth delegation proves that a user of your app owns a social account. You send them to PostSyncer, they sign in on the network’s own page, and they come back to your app with the network’s ID for that account, its handle and a signature you check with your secret. It’s for apps that need to know who owns an account, such as a creator marketplace checking a creator’s TikTok. It doesn’t connect the account to a PostSyncer workspace, and nothing in the proof lets you post as it. To post for your users, use connect links and the API.
PostSyncer keeps nothing from the sign-in: not the account, its tokens or the person’s details. The proof carries the account’s ID and handle, read from the network at sign-in.

Before you start

  1. An API key with accounts:create, the same permission as connect links. Keys made with “All permissions” have it. Make one in Settings → API. The key’s person must be active in PostSyncer.
  2. A signing secret on that key. In Settings → API, open the key’s menu (⋯) and choose Generate signing secret. Copy it: it’s shown once.
Keep the key and the secret on your server. The key never goes to the browser: you start each session from your backend. Anyone with the secret could make proofs that pass your check. To replace a leaked secret, choose Regenerate signing secret. Sessions started after that sign with the new secret. A session already started keeps the old one until it ends, up to 35 minutes later.

Networks

platform is one of these: Bluesky and Telegram don’t sign in with OAuth, and Mastodon signs in on each server, so none of the three can be used: a session for them is refused with unsupported_platform.

How it works

1. Start a session

From your server:
string
required
Bearer YOUR_API_KEY. The key needs accounts:create and a signing secret.
string
required
The network, from the table above, such as tiktok. Up to 64 characters.
string
required
The absolute URL in your app the user comes back to. Up to 2,048 characters. It may have its own query string: PostSyncer adds its values after it.
string
required
A random value you make for this session, up to 512 characters. Keep it on your server, tied to the user who started. It comes back unchanged.
It answers 200:
authorize_url works once, within expires_in seconds (15 minutes). It carries only a request token: no key, network or callback.

When starting fails

The key is checked first, then the body. Every error except the validation one has the same shape:
403
A missing or invalid platform, callback_url or state answers the usual validation 422 instead, with message and errors and no code. See Error handling.

2. Send the user to authorize_url

Redirect the user’s browser to authorize_url. PostSyncer sends them on to the network’s sign-in page.
  • The network asks the user to allow the same access as when an account is connected to PostSyncer, which can include posting. PostSyncer reads the account’s ID and handle and keeps nothing.
  • The sign-in must be finished within 20 minutes of opening the link.
  • On X, the user must finish in the same browser they started in.
  • The user doesn’t need a PostSyncer account.

3. The user comes back

With a proof

When the sign-in works, the user lands on your callback_url with six values added to its query:
string
The network you asked for.
string
The network’s own ID for the account. It doesn’t change, so it’s the value to store and match on.
string
The account’s username at sign-in, without a leading @. For showing only: people change handles. It can be empty, as the network table says.
string
Your state, unchanged.
integer
A Unix time 5 minutes after the sign-in. Refuse the proof after it.
string
The HMAC-SHA256 of platform={platform}&platform_id={platform_id}&handle={handle}&state={state}&expires={expires} with your signing secret, in lowercase hex.
Example callback
The values are URL-encoded in the query. The signature is made over the decoded values, as your framework hands them to you.

With an error

When something goes wrong, the user lands on your callback_url with error, error_description and your state, and no sig. Treat any callback with error as a failed check, and offer to start again with a new session.

Accept the first answer for a state

A user can come back more than once for the same session: with the Back button, a reload, or a second tab. After a proof, a second return for the same state arrives with error=invalid_state. Act on the first answer you get for a state, and once you’ve accepted a proof for it, ignore every later one.

When PostSyncer can’t send the user back

For a link PostSyncer never issued, or one more than about a day old, PostSyncer no longer knows your callback_url. The user then sees PostSyncer’s own page at /oauth/delegate?error=..., which says the link has expired, or that their account couldn’t be connected, and to go back to the app that sent them and start again. Your server gets nothing in that case, so let users start again from your side.

4. Check the proof

On your server, before you trust platform_id:
  1. state is one you issued for this user and haven’t used. Mark it used.
  2. expires is in the future.
  3. sig matches the HMAC you work out over the exact base string. Compare in constant time.
Only when all three pass is platform_id the account the user owns.

Limits

  • The delegation endpoints take 120 requests a minute from one IP address. See Rate limits.
  • Delegation works on every plan, Free included. Sessions don’t count as posts or as connected accounts.

Authentication

Make the key and choose its permissions.

Error handling

Every delegation error, with the API’s others.

Connect social accounts

Connect an account to post with it.