authenticateAppleIdToken

abstract suspend fun authenticateAppleIdToken(request: IOAuthAppleIDTokenAuthenticateParameters): OAuthGoogleIDTokenAuthenticateResponse

Authenticates an Apple ID token obtained via native iOS Sign In with Apple. Calls the POST /sdk/v1/oauth/apple/id_token/authenticate endpoint.

This method is called automatically by OAuthClient.apple start() on iOS — you typically only need to call it directly if you are supplying the ID token yourself.

Kotlin:

StytchConsumer.oauth.authenticateAppleIdToken(
OAuthAppleIDTokenAuthenticateParameters(
idToken = "apple-id-token",
sessionDurationMinutes = 30,
)
)

iOS:

let params = OAuthAppleIDTokenAuthenticateParameters(
idToken: "apple-id-token",
sessionDurationMinutes: 30
)
let response = try await StytchConsumer.oauth.authenticateAppleIdToken(params)

React Native:

StytchConsumer.oauth.authenticateAppleIdToken({ idToken: "apple-id-token", sessionDurationMinutes: 30 })

Return

OAuthGoogleIDTokenAuthenticateResponse containing the authenticated session and user.

Parameters

request
  • IOAuthAppleIDTokenAuthenticateParameters

  • idToken — The Apple ID token from Sign In with Apple.

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

  • name? — The user's name as provided by Apple on first sign-in (only returned once by Apple).

  • nonce? — The nonce used when requesting the ID token, for replay protection.

  • oauthAttachToken? — An OAuth attach token to link this provider to an existing session.

Throws

StytchError

if the ID token is invalid or expired.

if the coroutine is cancelled.