How shinhyo/signin-with-apple works
Project Type and Purpose
• This is an Android-centric multi-module library project (“sdk-signin-apple”) with a sample application (“sample”) demonstrating how to integrate Apple Sign-In in an Android app. It also includes “build-logic,” a Gradle convention-plugin module for shared build settings, and CI/CD workflows for publishing (via JitPack) and quality checks.
Main Components
a. Build System & CI/CD
• Gradle multi-project build
• Custom plugins in build-logic
• GitHub Actions workflows (.github/workflows/ci.yml and cd.yml)
• JitPack (artifact repository)
b. Runtime Modules
1. Sample App (sample module)
• UI layers (View system & Compose)
• Invokes the SignInWithApple SDK
2. SignInWithApple SDK (sdk-signin-apple module)
• Core OAuth/WebView flow
• State & nonce generation/validation
• JWT parsing
3. Android WebView
• Renders Apple’s OAuth pages
4. External Apple ID Server
• Authorizes the user, returns JWT (identity token) & authorization code
5. Your Backend (customer’s server)
• Verifies Apple’s JWT signature & nonce
• Exchanges authorization code for tokens
• Manages sessions/auth state
Relationships & Data Flows
• Build & Release Flow
• Developer → Gradle (using build-logic) → compile sdk-signin-apple & sample
• GitHub Actions → Run tests (sdk-signin-apple/src/test) → Publish SDK to JitPack
1. Sample App calls SignInWithApple.init(...) and signIn(context, nonce)
2. SDK generates state & nonce, then opens Android WebView with Apple OAuth URL
3. User authenticates on Apple ID Server page → Apple returns JWT + code to WebView
4. WebView redirects back into SDK → SDK validates state, extracts identityToken
5. SDK delivers AppleIdCredential (JWT) to the App via callback
6. App sends JWT to Your Backend
7. Backend verifies signature & nonce with Apple ID Server, exchanges code for tokens
8. Backend responds to App with session/auth success
Architectural Patterns & Principles
• Modularization: Clear separation between build logic (build-logic), core library (sdk-signin-apple), and consumer app (sample).
• Separation of Concerns:
• UI concerns in sample module (Activities, Compose)
• OAuth logic & security in sdk-signin-apple
• Plugin-based Build: Shared conventions for Android Compose, Hilt, Kotlin, code coverage via custom Gradle scripts.
• Secure OAuth Flow: Nonce & state for CSRF protection, server-side JWT verification.