Skip to main content

Embedded Sign-In

Cloud has the newest features. Some may not be in a release yet; the newest release is Identity & Access Management 7.3.0.

Use embedded sign-in when your application needs to advance the sign-in flow through JSON requests. Use it when you do not want to rely on a browser redirect for every interaction.

Embedded Sign-In​

1. Prerequisites​

  • express - cookie-parser - express.json() - mode: 'embedded' in your Express SDK configuration

2. Middleware and Route Setup​

index.js
const express = require('express');
const cookieParser = require('cookie-parser');
const {thunderID, handleFlow, handleSignIn, handleSignOut} = require('@thunderid/express');

const app = express();

app.use(cookieParser());
app.use(express.json());
app.use(
thunderID({
baseUrl: 'https://<DATA_PLANE_URL>',
clientId: '<your-client-id>',
clientSecret: '<your-client-secret>',
mode: 'embedded',
afterSignInUrl: 'http://localhost:3000/login',
afterSignOutUrl: 'http://localhost:3000/logout',
}),
);

app.post('/flow/sign-in', handleFlow());
app.get('/login', handleSignIn());
app.get('/logout', handleSignOut());

3. Request Lifecycle​

Start the Flow Send the first request without an executionId:​

{
"applicationId": "app-id",
"flowType": "SIGN_IN"
}

4. Response Lifecycle​

Continue rendering UI If the flow still needs more steps, handleFlow() returns:​

{
"authId": "...",
"challengeToken": "...",
"components": [],
"executionId": "...",
"flowStatus": "..."
}

5. How GET /login and POST /flow/sign-in Work Together​

  • POST /flow/sign-in advances the embedded interaction and eventually returns a redirect URL - GET /login completes the OAuth callback after the embedded flow returns the authorization code redirect Both routes are required for the embedded sign-in flow shown in the current SDK source.

6. Failure Cases​

handleFlow() returns 500 JSON responses when: - the SDK is not initialized because thunderID() was not mounted first - baseUrl is missing from the config - flow execution fails at runtime

Was this page helpful?