AI agents: read this documentation natively — index: https://docs.openvoidnet.com/llms.txt, full: https://docs.openvoidnet.com/llms-full.txt, this page: https://docs.openvoidnet.com/docs/identity/sign-in.md.
Sign in with Voidnet
Add Voidnet as an identity provider on your own site.
“Sign in with Voidnet” lets people authenticate with their Voidnet account and arrive at your site with a stable identity. You map that identity to the account you already have, exactly as you would with Google or Microsoft Entra.
Create a client
- Open Console → Sign in.
- Choose a type:
- Confidential for a website with a backend. You receive a secret, shown once.
- Public for a native app or a backend-for-frontend. No secret; PKCE is mandatory.
- Add at least one redirect URI. HTTPS is required; HTTP is accepted only for
localhost. - Optionally add post-logout redirect URIs, a logo, and policy links.
The client id looks like pub_…. The authorize, token, JWKS and logout endpoints are shown on the same page.
The flow
- Send the browser to the authorization endpoint with
response_type=code, yourclient_id, yourredirect_uri,scope=openid profile email, a randomstate, a randomnonce, and a PKCE challenge. - The user signs in at Voidnet and approves the request.
- Voidnet redirects back to your
redirect_uriwithcodeand the samestate. - Your backend exchanges the code at the token endpoint.
- Verify the
id_token, then readsub,email,email_verified,nameandpreferred_username.
import { createRemoteJWKSet, jwtVerify } from "jose";
const ISSUER = "https://oauth.openvoidnet.com";
const jwks = createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`));
export function authorizeUrl(clientId: string, redirectUri: string, state: string, nonce: string, challenge: string) {
const url = new URL(`${ISSUER}/oauth2/auth`);
url.searchParams.set("response_type", "code");
url.searchParams.set("client_id", clientId);
url.searchParams.set("redirect_uri", redirectUri);
url.searchParams.set("scope", "openid profile email");
url.searchParams.set("state", state);
url.searchParams.set("nonce", nonce);
url.searchParams.set("code_challenge", challenge);
url.searchParams.set("code_challenge_method", "S256");
return url.toString();
}
export async function exchange(clientId: string, clientSecret: string, code: string, redirectUri: string) {
const basic = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
const response = await fetch(`${ISSUER}/oauth2/token`, {
method: "POST",
headers: {
Authorization: `Basic ${basic}`,
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({ grant_type: "authorization_code", code, redirect_uri: redirectUri }),
});
if (!response.ok) throw new Error(`token exchange failed: ${response.status}`);
return response.json() as Promise<{ id_token: string; access_token: string }>;
}
export async function verify(idToken: string, clientId: string, expectedNonce: string) {
const { payload } = await jwtVerify(idToken, jwks, { issuer: ISSUER, audience: clientId });
if (payload.nonce !== expectedNonce) throw new Error("nonce mismatch");
return {
sub: String(payload.sub),
email: typeof payload.email === "string" ? payload.email : null,
emailVerified: payload.email_verified === true,
name: typeof payload.name === "string" ? payload.name : null,
};
}Public clients use PKCE instead of a secret: send code_challenge and code_challenge_method=S256 on the authorization request, and code_verifier on the token request, with no client secret.
A browser-only SPA exchanges the code through its own backend. Voidnet does not open the token endpoint to arbitrary origins.
Match the user
- Look up
(provider = "voidnet", sub). If it exists, that is your user. - Otherwise, if
email_verifiedis true and exactly one local user has that verified email, link it and storesub. - Otherwise, ask the user to link explicitly or create an account.
- Afterwards resolve by
subonly.
This is the same rule as call-time identity, so a user who signs in here is already resolved when their calls arrive through Voidnet.
Logout
Send the browser to the end-session endpoint with id_token_hint and one of your registered post-logout redirect URIs. Voidnet clears its session and returns to your site.
Errors
| Case | What happens |
|---|---|
| Unregistered redirect URI | The authorization request is rejected; nothing is redirected |
| Wrong or reused code | invalid_grant from the token endpoint |
| Nonce or state mismatch | Your own check rejects the response; do not trust it |
| Deleted client | New authorizations fail immediately; issued tokens expire within one hour |