start

abstract suspend fun start(parameters: B2BOAuthStartParameters): AuthenticatedResponse

Initiates an OAuth browser flow for the provider, scoped to the specified organization. Opens a browser session at https://{domain}/b2b/public/oauth/{provider}/start, then automatically exchanges the resulting token by calling POST /sdk/v1/b2b/oauth/authenticate, establishing a member session on success.

Kotlin:

val response = StytchB2B.oauth.google.start(
B2BOAuthStartParameters(
organizationId = "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl = "myapp://callback",
signupRedirectUrl = "myapp://callback",
sessionDurationMinutes = 30,
)
)

iOS:

let params = B2BOAuthStartParameters(
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl: "myapp://callback",
signupRedirectUrl: "myapp://callback",
sessionDurationMinutes: 30
)
let response = try await StytchB2B.oauth.google.start(params)

React Native:

StytchB2B.oauth.google.start({
organizationId: "org-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
loginRedirectUrl: "myapp://callback",
signupRedirectUrl: "myapp://callback",
sessionDurationMinutes: 30,
})

Return

AuthenticatedResponse containing the authenticated member session.

Parameters

parameters
  • B2BOAuthStartParameters

  • organizationId? — The ID of the organization to authenticate into.

  • organizationSlug? — The slug of the organization to authenticate into.

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

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

  • customScopes? — Additional OAuth scopes to request from the provider.

  • providerParams? — Provider-specific query parameters to append to the OAuth URL.

  • 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 OAuth flow fails or the token cannot be exchanged.

if the coroutine is cancelled.