Skip to content
Dashboard
Theme
Theme

iOS and macOS SDK

Sign end users in through the hosted login from Swift apps, with PKCE, Keychain storage and passkeys.

View Markdown

A Swift package for iOS 15+ and macOS 12+, with no dependencies.

// Swift Package Manager
.package(url: "https://github.com/ohauthcat/sdk-swift.git", exact: "0.0.2")
// CocoaPods
pod "OhAuthCat", "0.0.2"
  • Configure with Configuration(loginOrigin: https://login.ohauthcat.com, clientID: "pk_…", redirectURI: com.example.app:/oauth/callback) and create an OhAuthCatClient with a SystemWebAuthenticator.
  • signIn() opens the hosted login in ASWebAuthenticationSession with PKCE (S256), state and nonce. The callback must match the redirect URI exactly, and any iss in it must be the configured issuer.
  • Tokens are kept in the Keychain, on this device only and never synced.
  • accessToken() refreshes once for all concurrent callers. If the server reports a reused refresh token, the session is cleared.
  • signOut() clears the local session and, in OAuth provider mode, revokes the refresh token.
  • switchOrganization(_:) runs the hosted login again with organization_id.
  • Use mode: .oauth(environmentID:) to sign in against the environment’s OAuth provider instead, for scopes and revocation.
  • Passkeys inside the app go through a Passkeys(backend:authenticator:) seam; the hosted login already offers passkeys in the browser session.

The SDK checks the ID token’s claims but not its signature, since it comes directly from the token endpoint over TLS. Your backend must verify access tokens against the JWKS.