Skip to main content

Embedded Sign-In Flow (V1)

These functions implement app-native (embedded) sign-in for the V1 flow protocol. They allow you to drive the authentication sequence step-by-step without a browser redirect to the identity provider. Used internally by ThunderIDJavaScriptClient.getAgentToken().

note

For new integrations, prefer the V2 flow functions, which offer a richer response model and better error handling.

initializeEmbeddedSignInFlow(config)

Send an OAuth 2.0 authorization request directly to the ThunderID authorize endpoint and receive the first authentication step.

import { initializeEmbeddedSignInFlow } from '@thunderid/javascript'

const response = await initializeEmbeddedSignInFlow({
url: 'https://localhost:8090/oauth2/authorize',
payload: {
response_type: 'code',
client_id: '<your-client-id>',
redirect_uri: 'http://localhost:3000',
scope: 'openid profile',
state: '<random-state>',
code_challenge: '<pkce-code-challenge>',
code_challenge_method: 'S256',
response_mode: 'direct',
},
})

Parameters

ParameterTypeRequiredDescription
config.urlstringFull authorization endpoint URL (use instead of baseUrl)
config.baseUrlstringThunderID base URL. Mutually exclusive with url
config.payloadRecord<string, string>Authorization request parameters
config.payload.response_typestringMust be 'code'
config.payload.client_idstringApplication client ID
config.payload.redirect_uristringRedirect URI registered with the application
config.payload.scopestringSpace-separated scopes
config.payload.statestringRandom state for CSRF protection
config.payload.code_challengestringPKCE code challenge
config.payload.code_challenge_methodstringPKCE method (e.g., 'S256')
config.payload.response_modestringSet to 'direct' for embedded flows

Response: EmbeddedSignInFlowInitiateResponse

PropertyTypeDescription
flowIdstringUnique ID for this authentication flow
flowStatusEmbeddedSignInFlowStatusCurrent status of the flow
flowTypestringFlow type identifier
nextStepEmbeddedSignInFlowNextStepThe next required authentication step
linksEmbeddedSignInFlowLink[]Hypermedia links for the flow

EmbeddedSignInFlowNextStep

PropertyTypeDescription
stepTypeEmbeddedSignInFlowStepTypeType of the next step
authenticatorsEmbeddedSignInFlowAuthenticator[]Available authenticators for this step
messagesobject[]Messages to display to the user

EmbeddedSignInFlowAuthenticator

PropertyTypeDescription
authenticatorstringAuthenticator name (e.g., 'BasicAuthenticator')
authenticatorIdstringUnique authenticator identifier
idpstringIdentity provider name
metadataobjectAuthenticator-specific metadata
requiredParamsstring[]Parameters the authenticator requires (e.g., ['username', 'password'])

executeEmbeddedSignInFlow(config)

Submit the response for a flow step (e.g., credentials) and advance the flow.

import { executeEmbeddedSignInFlow } from '@thunderid/javascript'

const response = await executeEmbeddedSignInFlow({
baseUrl: 'https://localhost:8090',
payload: {
flowId: response.flowId,
selectedAuthenticator: {
authenticatorId: 'BasicAuthenticator-1',
params: {
username: 'user@example.com',
password: 'password123',
},
},
},
})

if (response.flowStatus === EmbeddedSignInFlowStatus.SuccessCompleted) {
// Exchange the authorization code for tokens
const { code, state, session_state } = response.authData
}

Parameters

ParameterTypeRequiredDescription
config.urlstringFlow execution endpoint URL
config.baseUrlstringThunderID base URL. Mutually exclusive with url
config.payloadobjectFlow step payload
config.payload.flowIdstringFlow ID from initializeEmbeddedSignInFlow()
config.payload.selectedAuthenticatorobjectAuthenticator selection and credentials
config.payload.selectedAuthenticator.authenticatorIdstringID of the chosen authenticator
config.payload.selectedAuthenticator.paramsRecord<string, string>Authenticator-specific input parameters

Response: EmbeddedSignInFlowHandleResponse

PropertyTypeDescription
flowStatusEmbeddedSignInFlowStatusFinal or intermediate status
authDataRecord<string, string>On success: authorization code, state, session_state

Enums

EmbeddedSignInFlowStatus

ValueDescription
IncompleteFlow has more steps to complete
SuccessCompletedAuthentication succeeded — authData contains the authorization code
FailCompletedAuthentication failed definitively
FailIncompleteA step failed but the flow can continue (e.g., wrong credentials)

EmbeddedSignInFlowStepType

ValueDescription
AUTHENTICATOR_PROMPTUser must provide credentials for an authenticator
MULTI_OPTIONS_PROMPTUser must choose between multiple authenticators

EmbeddedSignInFlowAuthenticatorParamType

ValueDescription
USER_PROMPTParameter requires user input
INIT_PARAMParameter is provided at flow initialization

EmbeddedSignInFlowAuthenticatorPromptType

ValueDescription
USER_PROMPTStandard credential prompt
INTERNAL_PROMPTHandled internally by the authenticator
REDIRECTION_PROMPTAuthenticator requires a redirect
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© WSO2 LLC. All rights reserved.Privacy PolicyCookie Policy