authenticate

abstract suspend fun authenticate(request: IB2BOAuthAuthenticateParameters): B2BOAuthAuthenticateResponse

Authenticates an OAuth token received via deeplink after a browser-based OAuth flow completes, establishing a member session. Calls the POST /sdk/v1/b2b/oauth/authenticate endpoint. Retrieves the PKCE code verifier stored during the B2BOAuthProviderClient.start call, and automatically includes the intermediate session token if one is present.

Use this method when handling deeplinks manually; prefer B2BOAuthProviderClient.start for the end-to-end flow.

Kotlin:

StytchB2B.oauth.authenticate(
B2BOAuthAuthenticateParameters(
oauthToken = "token",
sessionDurationMinutes = 30,
)
)

iOS:

let params = B2BOAuthAuthenticateParameters(oauthToken: "token", sessionDurationMinutes: 30)
let response = try await StytchB2B.oauth.authenticate(params)

React Native:

StytchB2B.oauth.authenticate({ oauthToken: "token", sessionDurationMinutes: 30 })

Return

B2BOAuthAuthenticateResponse containing the authenticated member session.

Parameters

request
  • IB2BOAuthAuthenticateParameters

  • oauthToken — The OAuth token extracted from the deeplink URL.

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

  • locale? — Locale for any follow-up communications.

Throws

StytchError

if the token is invalid, expired, or no PKCE verifier is found in storage.

if the coroutine is cancelled.