start

abstract suspend fun start(startParameters: OAuthStartParameters): AuthenticatedResponse

Initiates the browser-based OAuth flow for this provider and authenticates the result, establishing a session. On Android, opens a Custom Tab; on iOS, uses ASWebAuthenticationSession. Internally calls OAuthClient.authenticate, OAuthClient.authenticateGoogleIdToken, or OAuthClient.authenticateAppleIdToken depending on the provider and platform response.

Kotlin (Android):

StytchConsumer.oauth.google.start(
OAuthStartParameters(
activity = activity,
loginRedirectUrl = "myapp://oauth",
signupRedirectUrl = "myapp://oauth",
sessionDurationMinutes = 30,
)
)

iOS:

let params = OAuthStartParameters(
loginRedirectUrl: "myapp://oauth",
signupRedirectUrl: "myapp://oauth",
sessionDurationMinutes: 30,
oauthPresentationContextProvider: self
)
let response = try await StytchConsumer.oauth.google.start(params)

React Native:

StytchConsumer.oauth.google.start({
loginRedirectUrl: "myapp://oauth",
signupRedirectUrl: "myapp://oauth",
sessionDurationMinutes: 30,
})

Return

AuthenticatedResponse containing the authenticated session and user.

Parameters

startParameters
  • OAuthStartParameters

  • loginRedirectUrl? — Deep link URL to redirect existing users to after authorization.

  • signupRedirectUrl? — Deep link URL to redirect new users to after authorization.

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

  • providerParams? — Extra provider-specific query parameters to include in the authorization URL.

  • oauthAttachToken? — Attach token to link this provider to an existing session.

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

  • (Android only) activity — The Activity used to launch the Custom Tab.

  • (iOS only) applePresentationContextProvider — Presentation context for Sign In with Apple sheets.

  • (iOS only) oauthPresentationContextProvider — Presentation context for the web authentication session.

Throws

StytchError

if the OAuth flow fails or the resulting token cannot be authenticated.

if the coroutine is cancelled.