SDK

iOS SDK (Swift)

Native iOS authentication with OAuth 2.0 PKCE, Keychain storage, and Face ID / Touch ID support.

Key Features

OAuth 2.0 Authorization Code + PKCE
Secure Keychain token storage
Face ID / Touch ID (biometric auth)
Automatic token refresh
User info and roles
SwiftUI & UIKit support
Async/await API
Session management

Requirements

  • iOS 16+ / macOS 13+
  • Swift 5.9+
  • Xcode 15+

Installation

Add IdenplaneSDK via Swift Package Manager.

// In Xcode: File → Add Package Dependencies
// Enter repository URL:
https://github.com/idenplane/idenplane-ios

// Or in Package.swift:
dependencies: [
    .package(url: "https://github.com/idenplane/idenplane-ios", from: "1.0.0")
]

Configuration

Initialize the Idenplane client in your app delegate or SwiftUI App.

import IdenplaneSDK

let idenplane = IdenplaneClient(
    serverURL: "https://auth.example.com",
    realm: "my-realm",
    clientID: "my-ios-app",
    redirectURI: "myapp://callback"
)

Login with PKCE

The SDK handles the full OAuth 2.0 Authorization Code + PKCE flow.

// Present login screen
try await idenplane.login(presenting: viewController)

// Check authentication state
if idenplane.isAuthenticated {
    let accessToken = idenplane.accessToken
    let idToken = idenplane.idToken
}

Biometric Authentication

Enable Face ID / Touch ID for re-authentication using stored tokens from Keychain.

// Enable biometric login (stores tokens in Keychain)
try await idenplane.enableBiometrics()

// Login with Face ID / Touch ID
try await idenplane.loginWithBiometrics()

// Check if biometrics are available
let available = idenplane.isBiometricsAvailable

User Info

Retrieve the authenticated user profile.

let user = try await idenplane.getUserInfo()
print(user.name)       // "John Doe"
print(user.email)      // "[email protected]"
print(user.roles)      // ["admin", "user"]
print(user.attributes) // Custom attributes

Token Refresh

Tokens are refreshed automatically. You can also trigger a manual refresh.

// Automatic refresh happens before token expiry
// Manual refresh:
try await idenplane.refreshToken()

// Get fresh access token for API calls
let token = idenplane.accessToken

Logout

Logout clears tokens from Keychain and revokes the session.

try await idenplane.logout()
// Tokens cleared from Keychain
// Session revoked on server

SwiftUI Integration

Use the Idenplane client in SwiftUI views.

import SwiftUI
import IdenplaneSDK

struct ContentView: View {
    @StateObject private var auth = IdenplaneObservable(client: idenplane)

    var body: some View {
        if auth.isAuthenticated {
            VStack {
                Text("Welcome, \(auth.user?.name ?? "")")
                Button("Logout") { Task { try await auth.logout() } }
            }
        } else {
            Button("Sign In") { Task { try await auth.login() } }
        }
    }
}