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.urlstring✅Full authorization endpoint URL (use instead of baseUrl)
config.baseUrlstring✅ThunderID base URL. Mutually exclusive with url
config.payloadRecord<string, string>✅Authorization request parameters
config.payload.response_typestring✅Must be 'code'
config.payload.client_idstring✅Application client ID
config.payload.redirect_uristring✅Redirect URI registered with the application
config.payload.scopestring✅Space-separated scopes
config.payload.statestring✅Random state for CSRF protection
config.payload.code_challengestringNoPKCE code challenge
config.payload.code_challenge_methodstringNoPKCE method (e.g., 'S256')
config.payload.response_modestringNoSet 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.urlstring✅Flow execution endpoint URL
config.baseUrlstring✅ThunderID base URL. Mutually exclusive with url
config.payloadobject✅Flow step payload
config.payload.flowIdstring✅Flow ID from initializeEmbeddedSignInFlow()
config.payload.selectedAuthenticatorobject✅Authenticator selection and credentials
config.payload.selectedAuthenticator.authenticatorIdstring✅ID 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

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.