Continue With Sync
Let people sign in to your app with their Sync account. You get a verified identity and only the permissions the user approves. Your app's data stays on your own servers.
- Quick start
- 1. Send the user to sign in
- 2. Exchange the code
- 3. Read the user's data
- Permissions
- Expiry and revocation
- Try it
Quick start
Follow these four steps in order. Every URL below is exact. Only replace the values in CAPITALS and your own domain.
Step 1: create an app
- Open the Developer portal and sign in.
- Create an app with one authorised domain, such as
example.com. Use the bare domain, with no https://, path or port. - Add a logo link if you have one. It's optional, and people see it when they sign in. Use a direct https link to a square picture under 1 MB.
- Copy the client secret straight away. It is shown once.
Step 2: send the user to sign in
Open this URL in the user's browser. The user signs in, approves, and is redirected to your redirect URL with ?code= and your state.
https://auth.sync-ai.app/auth?site=My%20App&redirect=https://example.com/sync/callback&auth=name&auth2=email&state=RANDOM_STATE
Step 3: exchange the code (server only)
This must be a POST to exactly https://auth.sync-ai.app/oauth/token. It returns an access_token.
curl -X POST "https://auth.sync-ai.app/oauth/token" \
-H "Content-Type: application/json" \
-d '{"grant_type":"authorization_code","code":"CODE_FROM_REDIRECT","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://example.com/sync/callback"}'Step 4: read the user's data (server only)
curl "https://auth.sync-ai.app/api/userinfo" \ -H "Authorization: Bearer ACCESS_TOKEN"
Check your setup
Run this to confirm the endpoint is reachable before you write any code.
curl -i -X POST "https://auth.sync-ai.app/oauth/token" \
-H "Content-Type: application/json" \
-d '{"grant_type":"authorization_code","code":"test","client_secret":"test","redirect_uri":"https://example.com/x"}'
# Expected: HTTP 401 with {"error":"invalid_client",...}
# That proves the endpoint exists. Only your secret is wrong for real use.
# A 404 means the URL or method is wrong.Full server example
const SYNC = "https://auth.sync-ai.app";
const CLIENT_SECRET = process.env.SYNC_CLIENT_SECRET; // server only, never in browser code
const REDIRECT_URI = "https://example.com/sync/callback";
// Step 1: send the user here (use as a link or button)
function loginUrl(state) {
const u = new URL("/auth", SYNC);
u.searchParams.set("site", "My App");
u.searchParams.set("redirect", REDIRECT_URI);
u.searchParams.set("auth", "name");
u.searchParams.set("auth2", "email");
u.searchParams.set("state", state); // random value, saved in the user's session
return u.href;
}
// Step 2: your /sync/callback route calls this with the URL Sync redirected to
async function handleCallback(url, expectedState) {
if (url.searchParams.get("state") !== expectedState) throw new Error("state mismatch");
const code = url.searchParams.get("code");
if (!code) throw new Error("user cancelled or no code");
// Step 3: exchange the code (POST, server side)
const tokenRes = await fetch(SYNC + "/oauth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ grant_type: "authorization_code", code, client_secret: CLIENT_SECRET, redirect_uri: REDIRECT_URI }),
});
if (!tokenRes.ok) throw new Error("token exchange failed: " + tokenRes.status + " " + (await tokenRes.text()));
const { access_token } = await tokenRes.json();
// Step 4: read what the user approved
const infoRes = await fetch(SYNC + "/api/userinfo", { headers: { Authorization: "Bearer " + access_token } });
if (!infoRes.ok) throw new Error("userinfo failed: " + infoRes.status);
return infoRes.json(); // { sub, name, email }
}1. Send the user to sign in
Method: GET, opened in the user's browser. URL: https://auth.sync-ai.app/auth
| Parameter | Required | Meaning |
|---|---|---|
site | Yes | Your app's name. Shown only if the registry has no name. |
redirect | Yes | Where Sync sends the user afterwards. https only (http allowed for localhost). Its domain must be one of your app's authorised domains. |
auth, auth2, auth3, auth4 | No | Permissions to request: name, email, tasks, banned. Any other value is rejected. |
state | Recommended | Any random value. Sync returns it unchanged. Check it on return to prevent CSRF. Any other extra parameter is also returned unchanged. |
terms | No | https link to your Terms, shown on the consent page. |
privacy | No | https link to your Privacy policy, shown on the consent page. |
client_id | Only for Allow All Redirects apps | Your app's Client ID (32 hex characters). |
URL-encode every value in real code. The example below uses plain text for readability.
https://auth.sync-ai.app/auth?site=My%20App&redirect=https://example.com/sync/callback&auth=name&auth2=email&state=RANDOM_STATE
Where the user is sent next
| Outcome | Redirect to your redirect URL |
|---|---|
| Approved | https://example.com/sync/callback?state=RANDOM_STATE&code=CODE |
| Cancelled | https://example.com/sync/callback?state=RANDOM_STATE&error=access_denied |
2. Exchange the code
Method: POST. URL: https://auth.sync-ai.app/oauth/token. Body: JSON (Content-Type: application/json) or form-encoded.
| Field | Value |
|---|---|
grant_type | authorization_code (exact text) |
code | The code from the redirect. Single use, valid for 5 minutes. |
client_secret | Your app's secret from the Developer portal |
redirect_uri | The same redirect URL you sent in step 1, exactly |
Rules
- Use POST. A GET returns 405.
- The path is exactly
/oauth/token. Do not add/api. A trailing slash is accepted. - Run this on your server only. Never put the client secret in browser code.
- Each code works once. Requesting it again returns
invalid_grant.
Request
curl -X POST "https://auth.sync-ai.app/oauth/token" \
-H "Content-Type: application/json" \
-d '{"grant_type":"authorization_code","code":"CODE_FROM_REDIRECT","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"https://example.com/sync/callback"}'Success response (200)
{"access_token":"…","token_type":"Bearer","scope":"name email","inactive_expires_in_days":31,"max_lifetime_days":90}Errors
| Status | Meaning |
|---|---|
400 invalid_grant | Code is wrong, expired, already used, or redirect_uri does not match. |
401 invalid_client | client_secret is wrong, or redirect_uri is not an authorised domain of the app. |
400 unsupported_grant_type | grant_type must be exactly authorization_code. |
| 405 | You sent GET. Use POST. |
| 404 | Wrong URL. The path is /oauth/token, with no /api. |
3. Read the user's data
Method: GET. URL: https://auth.sync-ai.app/api/userinfo. Header: Authorization: Bearer ACCESS_TOKEN. No sign-in is needed.
sub is always returned: the user's stable Sync ID. Other fields appear only for permissions the user approved.
| Field | Needs permission | Value |
|---|---|---|
sub | Always | Stable user ID |
name | name | Display name, or null |
email | email | Email address, or null |
banned | banned | true or false |
tasks | tasks | The user's scheduled tasks, including prompts. Sensitive. |
Request
curl "https://auth.sync-ai.app/api/userinfo" \ -H "Authorization: Bearer ACCESS_TOKEN"
Example response
{"sub":"firebase-uid","name":"Luca","email":"you@example.com"}Errors
| Status | Meaning |
|---|---|
401 invalid_token | Header missing, token wrong, expired (31 days idle or 90 days old), or revoked. |
Permissions
Ask only for what you need. The user sees each permission before approving.
| Value | Shown to the user as | You receive |
|---|---|---|
name | See your full name | name |
email | See your email address | email |
tasks | See your scheduled tasks in Dash, including what you wrote in them | tasks: full task list, including prompts |
banned | Check if your account is banned | banned: true or false |
Expiry and revocation
- An access token expires after 31 days with no activity.
- It also ends 90 days after it was issued. The user then has to sign in again.
- Each call to
/api/userinfocounts as activity. - Authorization codes expire after 5 minutes and work once.
- If you delete an app in the Developer portal, its tokens stop working immediately.
- If you rotate the secret, the old one stops working immediately.
Try it
Each button opens the consent page. Continue returns to this site's test callback, which exchanges the code and shows the result. Use your own account.