> ## 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-wallet-kit`

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

### Overview

Handles the Apple OAuth flow.

<ul>
  <li>This function initiates the Apple OAuth flow by either redirecting the user to the Apple authorization page or opening it in a popup window.</li>
  <li>The flow type is determined by the `openInPage` parameter: if true, the current page is redirected; if false (default), a popup window is used.</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>If `openInPage` is true, the function redirects and returns a promise that resolves on redirect or times out after 5 minutes.</li>
  <li>If `openInPage` is false, a popup window is opened and the function returns a promise that resolves when the flow completes, or rejects if the window 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, popup 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 }`).

onOauthSuccess params:

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

Navigate to header

params.
openInPage

boolean

Whether to open the OAuth flow in the current page (redirect) or a popup window (default: false).

### 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.