EPerf Accounts

Use EPerf Accounts in your app

Register the app under Admin → Apps. You get a key like myapp:AbC…, shown once. Keep it in the app's server-side env file, never in the browser or the repo.

Option A: redirect sign-in (recommended)

  1. Send the browser to https://admin.eperf.ai/sso/login?app=SLUG&return=https://yourapp/auth/callback&state=RANDOM. The return address must be on the host you registered.
  2. The person signs in (or is already signed in) and comes back to your callback with ?ticket=…&state=…. Check that state matches what you sent.
  3. From your server, exchange the ticket (valid for 2 minutes, single use):
curl -s https://admin.eperf.ai/api/v1/verify-ticket \
  -H "Authorization: Bearer SLUG:SECRET" \
  -H "Content-Type: application/json" \
  -d '{"ticket":"TICKET"}'
# {"ok":true,"user":{"id":7,"username":"bob","email":"bob@x.com","name":"Bob","role":"user"}}

Then start your own session for that user. If the app is private and the person was not granted access, they are stopped at the sign-in step and you get no_access.

Option B: your own login form

If the app must keep its own username/password form, check the credentials here instead:

curl -s https://admin.eperf.ai/api/v1/authenticate \
  -H "Authorization: Bearer SLUG:SECRET" -H "Content-Type: application/json" \
  -d '{"username":"bob","password":"…"}'

Replies: 200 {ok:true,user}, 401 bad_credentials, 403 no_access / account_inactive, 429 rate_limited. The username field also accepts the email address.

New accounts

Link people to https://admin.eperf.ai/signup?next=%2Fsso%2Flogin%3Fapp%3DSLUG%26return%3Dhttps%3A%2F%2Fyourapp%2Fauth%2Fcallback. After they confirm their email they land back in your app.

Node example

const r = await fetch(process.env.ACCOUNTS_URL + '/api/v1/verify-ticket', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer ' + process.env.ACCOUNTS_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ ticket }),
});
const { ok, user } = await r.json();

PHP example

$ch = curl_init(getenv('ACCOUNTS_URL') . '/api/v1/verify-ticket');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('ACCOUNTS_KEY'), 'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode(['ticket' => $_GET['ticket']])]);
$res = json_decode(curl_exec($ch), true);

Python example

import os, requests
r = requests.post(os.environ['ACCOUNTS_URL'] + '/api/v1/verify-ticket',
    headers={'Authorization': 'Bearer ' + os.environ['ACCOUNTS_KEY']}, json={'ticket': ticket})
user = r.json()['user']