start

abstract suspend fun start(parameters: B2BSSOStartParameters): AuthenticatedResponse

Initiates an SSO authentication flow by opening a browser to the SSO provider. Opens a browser session at https://{domain}/b2b/public/sso/start, then automatically exchanges the resulting token by calling POST /sdk/v1/b2b/sso/authenticate, establishing a member session on success.

Kotlin:

val response = StytchB2B.sso.start(
B2BSSOStartParameters(
connectionId = "saml-connection-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl = "myapp://callback",
signupRedirectUrl = "myapp://callback",
sessionDurationMinutes = 30,
)
)

iOS:

let params = B2BSSOStartParameters(
connectionId: "saml-connection-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl: "myapp://callback",
signupRedirectUrl: "myapp://callback",
sessionDurationMinutes: 30
)
let response = try await StytchB2B.sso.start(params)

React Native:

StytchB2B.sso.start({
connectionId: "saml-connection-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl: "myapp://callback",
signupRedirectUrl: "myapp://callback",
sessionDurationMinutes: 30,
})

Return

AuthenticatedResponse containing the authenticated member session.

Parameters

parameters
  • B2BSSOStartParameters

  • connectionId — The ID of the SSO connection to authenticate with.

  • loginRedirectUrl? — URL to redirect to after a successful login.

  • signupRedirectUrl? — URL to redirect to after a successful sign-up.

  • sessionDurationMinutes? — Duration of the session to create, in minutes.

  • activity? (Android only) — The Android Activity used to launch the browser.

  • oauthPresentationContextProvider? (iOS only) — Presentation context for the ASWebAuthenticationSession.

Throws

StytchError

if the SSO flow fails or the token cannot be exchanged.

if the coroutine is cancelled.