Skip to main content

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 appScheme in your TurnkeyConfig; configure redirectUri in 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 in TurnkeyConfig:
DemoWalletApp.swift

Helper: presentation anchor

All OAuth helpers require an ASPresentationAnchor to present the system web auth session:
Anchor.swift

OIDC: Google and Apple

Use handleGoogleOAuth or handleAppleOAuth.
LoginView.swift
Optional parameters:
  • 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

Use handleDiscordOAuth or handleXOauth.
LoginView.swift

Advanced: onOAuthSuccess callback

If you pass onOAuthSuccess, 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, call completeOAuth(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.
For more information, refer to the Social Logins guide.

Next steps

Signing

Learn how to sign transactions and messages using wallets and accounts.