Skip to main content

Package: react-native-wallet-kit

Defined in: react-native-wallet-kit/src/providers/Types.tsx:227

Overview

Handles the Discord OAuth 2.0 flow.
  • This function initiates the OAuth 2.0 PKCE flow with Discord by opening the in-app browser and deep-linking back to the app.
  • On React Native, the flow always uses the in-app browser.
  • Generates a new ephemeral API key pair and uses its public key as part of the state and a cryptographic nonce to bind the OAuth session.
  • Creates a PKCE verifier/challenge pair, storing the verifier in AsyncStorage for later use in the token exchange.
  • Constructs the Discord OAuth URL with all required parameters, including client ID, redirect URI, response type, scope, PKCE code challenge, nonce, and state.
  • The state parameter encodes the provider name, flow type, ephemeral public key, and any additional key-value pairs provided in additionalState.
  • The flow resolves when the app is deep-linked back; it rejects if the in-app browser is closed or times out.
  • On receiving an authorization code, the function exchanges it for an OIDC token via the Turnkey proxy (proxyOAuth2Authenticate) using the PKCE verifier, redirect URI, and nonce.
  • 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.
  • Handles error cases such as missing configuration, in-app browser failures, missing PKCE verifier, or Turnkey proxy failures, throwing a TurnkeyError with appropriate error codes.

Parameters

params
HandleDiscordOauthParams

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.