> ## Documentation Index
> Fetch the complete documentation index at: https://docs.turnkey.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Turnkey is wallet infrastructure: create and manage crypto wallets, sign transactions, and enforce policy-based access controls. Best-fit uses: embedded consumer wallets (email/passkey/social auth, no seed phrases), automated onchain operations with server-side wallets, AI agent wallets with policy-scoped signing, enterprise key management, and verifiable off-chain workloads on Turnkey Verifiable Cloud (TVC).
> Every API call is a JSON POST to https://api.turnkey.com signed with a P-256 API key; create an organization and key self-serve at https://app.turnkey.com.
> Key Turnkey developer resources: API reference (https://docs.turnkey.com/api-reference/overview/intro.md), OpenAPI spec (https://docs.turnkey.com/public_api.swagger.json), authentication (https://docs.turnkey.com/features/authentication/overview.md), webhooks (https://docs.turnkey.com/features/webhooks/overview.md), MCP server for docs search (https://docs.turnkey.com/mcp), skill for building with Turnkey (https://docs.turnkey.com/skill.md), agent skills for operating an organization (https://docs.turnkey.com/get-started/ai-skills.md), CLI (https://docs.turnkey.com/sdks/cli.md), SDK reference (https://docs.turnkey.com/sdks/introduction.md), full docs content (https://docs.turnkey.com/llms-full.txt).

# handleAppleOauth()

**Package:** `react-native-wallet-kit`

**Defined in:** [react-native-wallet-kit/src/providers/Types.tsx:307](https://github.com/tkhq/sdk/blob/v2026.3.1/packages/react-native-wallet-kit/src/providers/Types.tsx#L307)

### Overview

Handles the Apple OAuth flow.

<ul>
  <li>This function initiates the Apple OAuth flow by opening the in-app browser and deep-linking back to the app.</li>
  <li>On React Native, the flow always uses the in-app browser.</li>
  <li>Generates a new ephemeral API key pair and uses its public key as the nonce for the OAuth request, ensuring cryptographic binding of the session.</li>
  <li>Constructs the Apple OAuth URL with all required parameters, including client ID, redirect URI, response type, response mode, nonce, and state.</li>
  <li>The `state` parameter includes the provider, flow type, public key, and any additional state parameters for tracking or custom logic.</li>
  <li>The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.</li>
  <li>On successful authentication, the function either calls the provided `onOauthSuccess` callback, triggers the `onOauthRedirect` callback from provider callbacks, or completes the OAuth flow internally by calling `completeOauth`.</li>
  <li>Handles all error cases, including missing configuration, in-app browser failures, and timeouts, and throws a `TurnkeyError` with appropriate error codes.</li>
</ul>

### Parameters

**params** `HandleAppleOauthParams`

**params details**

Navigate to header

params.
additionalState

Record\<string, string>

Additional key-value pairs to include in the OAuth state parameter for custom tracking or logic.

Navigate to header

params.
clientId

string

The Apple Client ID to use (defaults to the client ID from configuration).

Navigate to header

params.
onOauthSuccess

object

Callback function to handle the successful OAuth response (receives `{ oidcToken, providerName, publicKey }`).

onOauthSuccess params:

* oidcToken: The OIDC token received from the OAuth flow.
* providerName: The name of the OAuth provider ("apple").
* publicKey: The public key used for the OAuth flow.

### Response

A successful response returns the following fields:

**returns** `void` *required*

A promise that resolves when the OAuth flow is successfully initiated and completed, or rejects on error or timeout.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.