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 AuthmeSDK via Swift Package Manager.
// In Xcode: File → Add Package Dependencies
// Enter repository URL:
https://github.com/Islamawad132/authme-ios
// Or in Package.swift:
dependencies: [
.package(url: "https://github.com/Islamawad132/authme-ios", from: "1.0.0")
] Configuration
Initialize the AuthMe client in your app delegate or SwiftUI App.
import AuthmeSDK
let authme = AuthmeClient(
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 authme.login(presenting: viewController)
// Check authentication state
if authme.isAuthenticated {
let accessToken = authme.accessToken
let idToken = authme.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 authme.enableBiometrics()
// Login with Face ID / Touch ID
try await authme.loginWithBiometrics()
// Check if biometrics are available
let available = authme.isBiometricsAvailable User Info
Retrieve the authenticated user profile.
let user = try await authme.getUserInfo()
print(user.name) // "John Doe"
print(user.email) // "john@example.com"
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 authme.refreshToken()
// Get fresh access token for API calls
let token = authme.accessToken Logout
Logout clears tokens from Keychain and revokes the session.
try await authme.logout()
// Tokens cleared from Keychain
// Session revoked on server SwiftUI Integration
Use the AuthMe client in SwiftUI views.
import SwiftUI
import AuthmeSDK
struct ContentView: View {
@StateObject private var auth = AuthmeObservable(client: authme)
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() } }
}
}
}