Developer
Iniciar sesión
Documentation

Sign in with Xcojo

Xcojo Accounts is an OpenID Connect provider. Here’s everything a product needs.

Quickstart

1
Register your app
In this console. You get a client ID and a secret; the secret is shown once.
2
Store the secret server-side
In a private .env outside your web root. Never in JavaScript.
3
Send people to Accounts
Redirect to the authorize endpoint with a fresh random state and nonce.
4
Finish on your server
Check the state, exchange the code for a token, then read the profile.

Start sign-in (PHP)

session_start();
$_SESSION['state'] = bin2hex(random_bytes(32));
$_SESSION['nonce'] = bin2hex(random_bytes(32));
header('Location: https://accounts.xcojo.com/sso/authorize.php?' . http_build_query([
  'response_type' => 'code',
  'client_id'     => getenv('XCOJO_SSO_CLIENT_ID'),
  'redirect_uri'  => getenv('XCOJO_SSO_REDIRECT_URI'),
  'scope'         => 'openid profile email',
  'state'         => $_SESSION['state'],
  'nonce'         => $_SESSION['nonce'],
]));

Callback

if (!hash_equals($_SESSION['state'] ?? '', $_GET['state'] ?? '')) exit('Invalid state');

// Exchange the one-time code (valid 2 minutes) for an access token (valid 5 minutes)
$token = post_json('https://accounts.xcojo.com/sso/token.php', [
  'client_id' => getenv('XCOJO_SSO_CLIENT_ID'), 'client_secret' => getenv('XCOJO_SSO_CLIENT_SECRET'),
  'code' => $_GET['code'], 'redirect_uri' => getenv('XCOJO_SSO_REDIRECT_URI'),
]);

// Read the profile
$me = get_json('https://accounts.xcojo.com/sso/userinfo.php', ['Authorization: Bearer ' . $token['access_token']]);
// $me['sub'] is the stable Xcojo ID — key your users on it, not on email.

Platform APIs

One API key (xk_live_…) works with every platform API. Create keys in API keys and send them as Authorization: Bearer <key> (or X-Xcojo-Key). Responses are JSON with ok; limits reset at midnight UTC and are reported in X-RateLimit-* headers.

EndpointWhat it doesFree / dayPro / day
https://astromark.xcojo.com/api/v1/geocode.php?q=Bole+MedhanialemSearch addresses and places (Astromark learns from every answer)1,00050,000
https://astromark.xcojo.com/api/v1/reverse.php?lat=9.01&lng=38.76The address at a point1,00050,000
https://astromark.xcojo.com/api/v1/route.php?from=9.03,38.74&to=8.99,38.79&mode=carDriving, walking or cycling routes with turn-by-turn steps20010,000
https://astromark.xcojo.com/api/v1/places.php?lat=9.01&lng=38.76&q=pharmacyPlaces near a point50020,000
https://astromark.xcojo.com/api/v1/position.phpPOST live positions for your fleet; GET who’s near a point (Pro)—50,000
https://astromark.xcojo.com/tiles/{z}/{x}/{y}.pngMap tiles for Leaflet, MapLibre or any slippy map (no key needed)Fair useFair use
https://verification.xcojo.com/api/v1/check.php?code=ABCDE-FGHJKIs a document verified? Who issued it, when, and is it still valid50020,000
https://jolt.xcojo.com/api/v1/news.php?country=ET&category=businessLatest stories from Jolt news and channels1,00025,000
https://dev.xcojo.com/api/v1/ai.phpXcojo AI chat completions — POST {"messages":[…]} (Pro)—1,000

Example — geocode and route (JavaScript, from your server)

const H = { Authorization: 'Bearer ' + process.env.XCOJO_API_KEY };
const g = await (await fetch('https://astromark.xcojo.com/api/v1/geocode.php?q=' + encodeURIComponent('Bole Medhanialem, Addis Ababa'), { headers: H })).json();
const p = g.results[0];
const r = await (await fetch(`https://astromark.xcojo.com/api/v1/route.php?from=${p.lat},${p.lng}&to=9.0054,38.7636&mode=car`, { headers: H })).json();
console.log(r.routes[0].distance_m, r.routes[0].duration_s);

Example — check a verified document (PHP)

$r = json_decode(file_get_contents('https://verification.xcojo.com/api/v1/check.php?code=' . urlencode($code), false, stream_context_create(['http' => ['header' => 'Authorization: Bearer ' . getenv('XCOJO_API_KEY')]])), true);
if ($r['ok'] && $r['state'] === 'valid') echo 'Issued by ' . $r['issuer']['name'];
Keys are secrets. Call the APIs from your server. For browser apps, create a key with your site listed under “Allowed websites” — other sites can’t use it.

API reference

EndpointMethodPurpose
https://accounts.xcojo.com/.well-known/openid-configurationGETDiscovery document with every endpoint below
https://accounts.xcojo.com/sso/authorize.phpGETStarts sign-in. Params: response_type=code, client_id, redirect_uri, scope, state, nonce
https://accounts.xcojo.com/sso/token.phpPOST (JSON)Code → access token. Body: client_id, client_secret, code, redirect_uri
https://accounts.xcojo.com/sso/userinfo.phpGETProfile for a bearer token: sub, first_name, last_name, connect_handle, email, avatar_url
https://accounts.xcojo.com/sso/jwks.phpGETPublic keys for verifying ID token signatures (RS256)
https://accounts.xcojo.com/api/sso_validate.phpPOST (JSON)Single sign-on: validate a visitor’s xco_sso cookie. Body: client_id, client_secret, sso_token
https://accounts.xcojo.com/api/logout.phpGETEnds the visitor’s Xcojo session everywhere

Single sign-on across *.xcojo.com

People signed in to any Xcojo product carry a xco_sso cookie for .xcojo.com. Your server can recognise them without a redirect:

$r = post_json('https://accounts.xcojo.com/api/sso_validate.php', [
  'client_id' => getenv('XCOJO_SSO_CLIENT_ID'),
  'client_secret' => getenv('XCOJO_SSO_CLIENT_SECRET'),
  'sso_token' => $_COOKIE['xco_sso'] ?? '',
]);
if ($r['ok']) { /* $r['user']['xcojo_uid'], first_name, connect_handle … */ }
Checklist: exact https callback · single-use state and nonce · exchange codes only on your server · key accounts on sub · rotate the secret if it ever leaks.

Payments & Ads APIs

Sponsored placements (Xcojo Ads)

First-party pages on *.xcojo.com can request contextual, location-targeted ads. No personal data is sent; location is worked out by Xcojo from the network.

GET https://ads.xcojo.com/api/serve.php?placement=xcojo_sites&q=coffee&lang=en&n=1

{ "ok": true, "ads": [ { "label": "Sponsored", "advertiser": "…", "headline": "…",
  "description": "…", "display_url": "…", "click_url": "…", "why": "…" } ] }

Show label at the same size as the headline, link the whole ad to click_url, and offer why behind a “Why this ad?” control.

Xcojo Payments

Xcojo products share one double-entry ledger: people hold balances, top up with Chapa or Stripe, send money and withdraw. Partner products can send people to https://pay.xcojo.com/add.php to add money. A public merchant API (charges, refunds, webhooks for third-party apps) is on the roadmap.

Design & assets

Every Xcojo surface follows Connect Design: EB Garamond, the shared colour foundation, one accent, line icons, calm motion. Assets are served by https://dev.xcojo.com.

AssetURL
Fonts (EB Garamond)https://dev.xcojo.com/Fonts/?family=EB+Garamond:wght@400;500;600;700
Xcojo logohttps://dev.xcojo.com/Logo/Xcojo%20logo.png
Xcojo markhttps://dev.xcojo.com/Logo/X%20logo%20xcojo.png
Favicon sethttps://dev.xcojo.com/Favicon/?type=favicon · ?type=size&size=32 · ?type=apple · ?type=manifest
Iconshttps://dev.xcojo.com/Icon/?name=search&size=24&color=currentColor
Soundshttps://dev.xcojo.com/Audio/?sound=signature
Hapticshttps://dev.xcojo.com/Haptic/?pattern=selection (returns {"web":[…]})
<link rel="stylesheet" href="https://dev.xcojo.com/Fonts/?family=EB+Garamond:wght@400;500;600;700&display=swap">
:root { --c-bg:#FAF8F3; --c-surface:#FFFFFF; --c-text:#1C1A16; --c-muted:#5C574D; --c-border:#E6E1D6; --xco-accent:#0F766E; }
@media (prefers-color-scheme: dark) { :root { --c-bg:#0E0D0B; --c-surface:#1A1815; --c-text:#F2EEE4; --c-muted:#A8A194; --c-border:#2E2B25; } }