Overview
This guide shows how to implement social logins with the Turnkey Swift SDK.The SDK launches the provider in the system browser, retrieves an OIDC token, and (by default) completes login or signup through the Auth Proxy. The examples below use SwiftUI, but the SDK works with any Swift framework. Turnkey supports any OIDC provider. The SDK provides convenience helpers for popular providers (Google, Apple, Discord, X). For other providers, run your own OAuth flow to obtain an OIDC token and complete authentication with
completeOAuth(oidcToken:publicKey:...).
Before you begin:
- Ensure you’ve completed the setup in Getting Started.
- Set provider client IDs and
appSchemein yourTurnkeyConfig; configureredirectUriin the Turnkey Dashboard (Auth Proxy). - Add your app scheme to iOS URL Types (Info.plist) so the OAuth redirect returns to your app.
Configure providers
Define your app scheme and provider client IDs directly inTurnkeyConfig:
DemoWalletApp.swift
Helper: presentation anchor
All OAuth helpers require anASPresentationAnchor to present the system web auth session:
Anchor.swift
OIDC: Google and Apple
UsehandleGoogleOAuth or handleAppleOAuth.
LoginView.swift
clientId: Override the configured client ID.sessionKey: Store the resulting session under a custom key.additionalState: Append extra key-value pairs to the OAuth request state.
OAuth2 PKCE: Discord and X
UsehandleDiscordOAuth or handleXOauth.
LoginView.swift
Advanced: onOAuthSuccess callback
If you passonOAuthSuccess, the helper returns early with the oidcToken and the publicKey associated with the session.
You can then call completeOAuth(...) yourself (for example, to customize sessionKey or sub-organization creation).
LoginView.swift
Wrap async work in a
Task since the callback is not async.Using completeOAuth directly
If you already obtained an OIDC token from your own OAuth flow, callcompleteOAuth(oidcToken:publicKey:...) to finish authentication via the Auth Proxy.
The
publicKey must match the key used to compute the nonce included in the
OIDC token.Next steps
Signing
Learn how to sign transactions and messages using wallets and accounts.