authenticate

abstract suspend fun authenticate(request: IOAuthAuthenticateParameters): OAuthAuthenticateResponse

Authenticates an OAuth token received from a deeplink after the browser-based OAuth flow completes. Calls the POST /sdk/v1/oauth/authenticate endpoint. Retrieves the PKCE code verifier stored during the corresponding OAuthType.start call.

This method is called automatically by OAuthType.start when using the browser flow — you typically only need to call it directly if you are handling the deeplink redirect yourself.

Kotlin:

StytchConsumer.oauth.authenticate(
OAuthAuthenticateParameters(token = "token", sessionDurationMinutes = 30)
)

iOS:

let params = OAuthAuthenticateParameters(token: "token", sessionDurationMinutes: 30)
let response = try await StytchConsumer.oauth.authenticate(params)

React Native:

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

Return

OAuthAuthenticateResponse containing the authenticated session and user.

Parameters

request
  • IOAuthAuthenticateParameters

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

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

Throws

StytchError

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

if the coroutine is cancelled.