Skip to main content

Your First Application

This is the step between having Idenplane running and having it actually authenticate someone. By the end you will have a realm, a registered client, and a page that signs a user in and reads their claims.

If you have not installed Idenplane yet, start with Installation.


The fast path: the setup wizard​

A fresh instance serves a six-step wizard in the admin console at /console/setup that does all of this for you. Sign in first as a super-admin: the initial admin from ADMIN_USER / ADMIN_PASSWORD, or the ADMIN_API_KEY. The wizard API (/setup-wizard/*) accepts the same credentials as the Admin API and only the super-admin role.

StepWhat it does
1. Create Admin AccountThe admin user of the new realm
2. Configure Realm SettingsNames the realm and sets its basics
3. Setup SMTPOptional — skip it if you are not sending email yet
4. Create First ClientRegisters a public OAuth client
5. SDK IntegrationShows the snippet for your framework
6. Test AuthenticationRuns a login against what you just built

Step 6 is the part worth not skipping: it proves the whole chain works before you write any of your own code.

The wizard runs once. After it is completed or skipped, every write to it answers 409 Conflict ("Setup is already complete") and the console page links to the console instead of showing the form. POST /setup-wizard/reset only clears the answers of a wizard still in progress; it never touches realms or users, and it is refused after setup too.

The rest of this page is the same thing done by hand — useful if the wizard has already been completed, or if you are scripting a new environment.


1. Create a realm​

A realm is an isolated set of users, clients and roles. Applications that should not share accounts belong in different realms.

In the console at /console/realms, click Create Realm. Or over the API:

curl -X POST http://localhost:3000/admin/realms \
-H "x-admin-api-key: $ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"my-realm","displayName":"My Realm","enabled":true}'

2. Register a client​

A client is one application. Browser and mobile apps are public clients — they cannot keep a secret, so they authenticate with PKCE instead.

In the console, open your realm and go to Clients → Create. The fields that matter:

FieldValue for a browser app
Client IDAnything stable, e.g. my-web-app
Client typePublic — a browser cannot hold a secret
Grant typesauthorization_code (the default) — this is Authorization Code + PKCE
Redirect URIsExactly where Idenplane may send users back, e.g. http://localhost:5173/callback
Web originsYour app's origin, for CORS
warning

Redirect URIs are matched exactly, and they are a security boundary — anything listed here can receive an authorization code. Do not add wildcards or origins you do not control.

Over the API:

curl -X POST http://localhost:3000/admin/realms/my-realm/clients \
-H "x-admin-api-key: $ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"clientId": "my-web-app",
"name": "My Web App",
"clientType": "PUBLIC",
"grantTypes": ["authorization_code", "refresh_token"],
"redirectUris": ["http://localhost:5173/callback"],
"webOrigins": ["http://localhost:5173"]
}'

3. Create a user​

Users → Create in the console, or:

curl -X POST http://localhost:3000/admin/realms/my-realm/users \
-H "x-admin-api-key: $ADMIN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"username":"alice","email":"alice@example.com","enabled":true}'

Set a password from the user's detail page, or with PUT /admin/realms/my-realm/users/{id}/reset-password and a body of {"password": "..."}.


4. Wire it into your app​

Install the SDK:

npm install idenplane-sdk

Point it at the client you just registered:

import { IdenplaneClient } from 'idenplane-sdk';

export const auth = new IdenplaneClient({
url: 'http://localhost:3000',
realm: 'my-realm',
clientId: 'my-web-app',
redirectUri: `${window.location.origin}/callback`,
});

On startup, restore any existing session and send the user to log in if there isn't one:

const isAuthenticated = await auth.init();
if (!isAuthenticated) {
await auth.login();
}

On the /callback route — the URL you registered above — finish the exchange:

const success = await auth.handleCallback();
if (success) {
window.location.replace('/');
}

Using React, Vue, Angular or Next.js? The framework packages wrap the same client — see the SDK guides.


5. Confirm it worked​

Once init() returns true:

const user = auth.getUserInfo();
console.log(user?.preferred_username); // alice

const claims = auth.getTokenClaims();
console.log(claims?.sub, claims?.exp);

If you get that far, the realm, the client, the redirect URI and the token exchange are all correct.


When it doesn't work​

SymptomUsual cause
400 Invalid redirect_uriThe redirectUri in your config is not listed on the client, character for character
CORS error in the consoleYour app's origin is missing from the client's Web origins
"Client does not support authorization_code grant"authorization_code is missing from the client's grant types
unauthorized_client at the token endpointThe grant type you used is not in the client's grant types
Login succeeds, init() still returns falsestorage is memory (the default) and you reloaded — expected, see Choosing a storage type
"Client not found"The clientId does not exist, or is disabled, in the realm you named

Realm Events in the console records failed authentication attempts with a reason, which is usually faster than guessing.


Next steps​

JavaScript SDK The full client API

Authentication OAuth 2.0 flows in depth

Authorization Roles, scopes and permissions