OAuth Delegation
OAuth delegation lets a third-party app connect a user’s social media account through PostSyncer and receive back a signed proof of ownership for that account. It works for any platform PostSyncer supports that uses OAuth (TikTok, Instagram, X/Twitter, LinkedIn, YouTube, Facebook, Pinterest, Threads). Instead of integrating each platform’s OAuth yourself, you redirect the user to PostSyncer, PostSyncer runs the platform OAuth, and then redirects the user back to you with the platform’s permanent user id, the handle, and an HMAC-SHA256 signature you can verify with your signing secret.Delegation does not store a social account on your PostSyncer workspace. The
platform_id and handle are read directly from the platform’s OAuth response
and passed through to you - nothing else is persisted.Prerequisites
- A PostSyncer API key (create one).
- A signing secret for that API key. In Settings → API Keys, click the shield icon on the API key row and choose Generate signing secret. Copy it - it’s shown only once. Regenerating invalidates the previous secret.
Flow overview
Step 1 - Create a delegation session (server-to-server)
From your backend, call:Authorization header:
Bearer <your PostSyncer API key>. Sent server-to-server only - never exposed
to the browser.The platform to connect, e.g.
tiktok, instagram, twitter, linkedin,
youtube, facebook, pinterest, threads.Absolute URL PostSyncer redirects the user back to after authentication.
A random, single-use string you generate. Used for CSRF protection; PostSyncer
echoes it back unchanged.
Node.js
Step 2 - Redirect the user to the authorize URL
Send the user’s browser to theauthorize_url you received. It carries only an
opaque request token - no API key, platform or callback URL.
Node.js
Step 3 - PostSyncer redirects back to your callback_url
On success, PostSyncer redirects the user to your callback_url with:
The platform that was connected.
The platform’s permanent unique identifier for the user (e.g. TikTok
open_id,
X user_id, Instagram user_id). This is the value you trust as ownership proof.The username on that platform. For display only - handles can change.
The same value you sent in step 1.
Unix timestamp, 5 minutes from when the proof was issued.
HMAC-SHA256 signature of the string
platform={platform}&platform_id={platform_id}&handle={handle}&state={state}&expires={expires}
using your signing secret.Example callback
callback_url with error, error_description, and state instead.
Step 4 - Verify the proof
On your server, before trustingplatform_id:
- Verify
statematches the value you generated and mark it as used (single use). - Verify
sigby recomputing the HMAC over the exact base string. - Verify
expiresis in the future.
platform_id as verified ownership.
Errors
Step 1 (session creation) returns a JSON error to your server with an HTTP 4xx status and acode:
No API key was provided in the
Authorization header. (401)The API key is invalid or expired. (401)
The API key has no signing secret. Generate one under Settings → API Keys. (422)
The
platform value is not a supported OAuth platform. (422)callback_url with an error, error_description and state instead of a
signed proof:
The user cancelled or declined the platform consent screen.
The platform OAuth did not complete.
The authorize URL was already used or expired before the user opened it.
The signature only covers successful proofs. Always treat any response that
carries an
error parameter as a failed connection.