Quickstart
Sign in with Atheron in your language: settings, the sign-in link, the code swap and who signed in. Pick a language once and every block follows.
Inicie sesión para ver su propio ID de cliente de prueba en los ejemplos.
Four steps, each in cURL and every SDK language. Pick your language in any block or at the top of the page: every block switches, and the docs remember it. Signed in, the samples carry your own test client ID.
1. Settings
Register an app in the portal first. Its test client works straight away for your team and up to 25 testers. Put these in your server's environment, never in code you ship to a browser.
Add http://localhost:3000/auth/callback as a redirect address of your test environment in the portal. Addresses are matched exactly. An https address needs its domain verified first (Verifying your domain).
ATHERON_ISSUER=https://accounts.aton-network.org
ATHERON_CLIENT_ID=test-xxxxxxxxxxxxxxxx
ATHERON_CLIENT_SECRET=ath_cs_...
ATHERON_REDIRECT_URI=http://localhost:3000/auth/callback2. Send the person to us
Make a fresh PKCE pair, a state and a nonce for this browser, keep them in an HTTP-only cookie or the session, and redirect to the address this gives you. The SDKs do all of it in one call.
# The authorize request is a page the person opens, not an API call. Build the address on your
# server: a fresh PKCE pair, state and nonce for this browser, then redirect them to it.
VERIFIER=$(openssl rand -base64 32 | tr '+/' '-_' | tr -d '=\n')
CHALLENGE=$(printf '%s' "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 | tr '+/' '-_' | tr -d '=\n')
STATE=$(openssl rand -hex 16)
echo "https://accounts.aton-network.org/oauth/authorize?response_type=code&client_id=$ATHERON_CLIENT_ID&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback&scope=openid%20profile%20email&state=$STATE&code_challenge=$CHALLENGE&code_challenge_method=S256"(no body: the browser follows the redirect)3. Swap the code for tokens
We send the person back to your redirect address with a one-time code. Check the state matches the one you kept, then swap the code on your server. It is valid for one use and a short time.
# Swap the code from the redirect for tokens, on your server. HTTP Basic carries your client ID and
# secret; the verifier proves this is the browser that started the sign-in.
curl https://accounts.aton-network.org/oauth/token \
-u "$ATHERON_CLIENT_ID:$ATHERON_CLIENT_SECRET" \
-d grant_type=authorization_code \
-d code="$CODE" \
-d redirect_uri=https://app.example.com/callback \
-d code_verifier="$VERIFIER"{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6ImF0K2p3dCJ9...",
"token_type": "Bearer",
"expires_in": 900,
"scope": "openid profile email offline_access",
"id_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjIwMjYtMTAtMDEiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmF0b24tbmV0d29yay5vcmciLCJzdWIiOiI5YTZk...",
"refresh_token": "ath_rt_6Qm9..."
}4. Read who signed in
The ID token says who signed in, as of sign-in. Its sub is the person's ID for your app alone, and never changes. Ask userinfo when something may have changed since, such as a membership.
# Who the person is as of now, with an access token issued to your client.
curl https://accounts.aton-network.org/oauth/userinfo \
-H "Authorization: Bearer $ACCESS_TOKEN"{
"sub": "9a6d4c1e-1f0b-4a51-8a8e-3b2f6c0d7e11",
"name": "Ada Lovelace",
"email": "ada@example.com",
"email_verified": true,
"age": { "verified": true, "adult": true, "sixteen_or_over": true }
}In your framework
The SDKs wire all four steps into your framework's routes and sessions. Pick a framework inside the block where your language has more than one.
Next: protect a page, refresh and sign out, and go live.
// app/auth/[...atheron]/route.ts: every Sign in with Atheron route in one file.
// Set ATHERON_CLIENT_ID, ATHERON_CLIENT_SECRET, ATHERON_SECRET and
// ATHERON_REDIRECT_URI=https://your.app/auth/callback (the address you registered).
import { Atheron } from "@aton-network/nextjs";
const atheron = Atheron();
export const { GET, POST } = atheron.handlers;Pregunte a Atlas
Asistente de IAPregunte lo que quiera sobre Iniciar sesión con Atheron, la API o el portal. La respuesta sale de nuestra documentación, con enlaces a las páginas usadas.