# Mobile Authentication Overview

We currently rely on [Clerk](https://clerk.dev) for authentication in iOS and Android apps. The iOS platform uses the official [Clerk iOS SDK](https://github.com/clerk/clerk-ios), while Android implements a custom HTTP-based integration with Clerk's REST API.

## Configuration

| Configuration             | iOS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Android                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **SDK Version**           | Clerk iOS SDK v0.54.1 <br>[`Package.swift#L115`](https://github.com/suno-ai/app-ios/blob/develop/Package.swift#L115)                                                                                                                                                                                                                                                                                                                                                                       | Custom HTTP integration targeting Clerk JS v5.15.0 <br>[`ClerkService.kt#L11`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L11)                                                                                                                                                                                                                                                      |
| **API Version**           | v1 (handled by SDK) <br>**SDK Implementation**: All Clerk iOS SDK services use `/v1/client/*` endpoints internally <br>[`SignInService.swift`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignIn/SignInService.swift), [`SignUpService.swift`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignUp/SignUpService.swift), [`ClientService.swift`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Client/ClientService.swift) | v1 (explicit in endpoints) <br>[`ClerkService.kt#L15-98`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L15-98)                                                                                                                                                                                                                                                                        |
| **Base URL & Authentication** | **Production**: `clerk.suno.com` (inferred from publishable key) <br>**Staging**: `clerk.suno.fm` (inferred from publishable key) <br>**Publishable Keys**: <br>• Production: `pk_live_Y2xlcmsuc3Vuby5jb20k` [`suno-production-debug.xcconfig#L10`](https://github.com/suno-ai/app-ios/blob/develop/suno/Config/suno-production-debug.xcconfig#L10) <br>• Staging: `pk_live_Y2xlcmsuc3Vuby5mbSQ` [`suno-staging-debug.xcconfig#L10`](https://github.com/suno-ai/app-ios/blob/develop/suno/Config/suno-staging-debug.xcconfig#L10) | **Production**: `https://clerk.suno.com/` <br>[`EnvironmentConstants.kt (prod)`](https://github.com/suno-ai/app-android/blob/main/common-core-utils/src/prod/java/com/suno/android/common_core_utils/environment/EnvironmentConstants.kt) <br>**Staging**: `https://clerk.suno.fm/` <br>[`EnvironmentConstants.kt (staging)`](https://github.com/suno-ai/app-android/blob/main/common-core-utils/src/staging/java/com/suno/android/common_core_utils/environment/EnvironmentConstants.kt) <br>**Publishable Keys**: Not used (custom HTTP integration) |
| **Redirect URI**          | Handled by SDK internally <br>**SDK Implementation**: OAuth flows use URL scheme `clerk.suno.com://` or `clerk.suno.fm://` with SDK's built-in redirect handling <br>[`ClerkClient.swift#L546-613`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L546-613) OAuth methods handle URL callbacks automatically                                                                                                                                       | **Production**: `https://suno.com/oauth-redirect-v2` <br>**Staging**: `suno://b.suno.fm/oauth-redirect-v2` <br>[`EnvironmentConstants.kt`](https://github.com/suno-ai/app-android/blob/main/common-core-utils/src/staging/java/com/suno/android/common_core_utils/environment/EnvironmentConstants.kt)                                                                                                                                                                                    |
| **Client Identification** | SDK handles automatically <br>**SDK Implementation**: SDK includes device info and platform identification in all API requests via internal headers <br>Configured via publishable key validation and environment detection                                                                                                                                                                                                                                                                | `_is_native=true` metadata header <br>[`ClerkMetadataHeaderInterceptor.kt`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/interceptors/ClerkMetadataHeaderInterceptor.kt)                                                                                                                                                                                                                                    |

## Session Management

| Aspect                       | iOS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Android                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Session Creation**         | **Code**: [`ClerkClient.swift#L258-304`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) `signInWithPhone()` and OAuth methods <br>**SDK Implementation**: [`SignInService.swift#L23-31`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignIn/SignInService.swift#L23-31) `create()` method calls `POST /v1/client/sign_ins` <br>**Token Generation**: [`SessionTokenFetcher.swift#L66-71`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Session/SessionTokenFetcher.swift#L66-71) handles `POST /v1/client/sessions/{id}/tokens`                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | **Code**: [`AuthManager.kt#L1-305`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt#L1-305) orchestrates flows <br>**API Calls**: Direct `POST /v1/client/sign_ins` via [`ClerkService.kt#L49-55`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L49-55) <br>**Token Generation**: `POST /v1/client/sessions/{id}/tokens` via [`ClerkService.kt#L15-21`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L15-21) |
| **Session Data**             | **Tokens**: JWT tokens + long-lived session tokens (SDK managed) <br>**SDK Implementation**: [`SessionTokenFetcher.swift#L20-71`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Session/SessionTokenFetcher.swift#L20-71) handles token caching and refresh <br>**User Data**: Complete user profile via SDK <br>**SDK Implementation**: [`User.swift`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/User/User.swift) model populated from `/v1/client` responses <br>**Storage**: Keychain via SDK's secure storage <br>**SDK Implementation**: Internal keychain wrapper handles automatic persistence                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Tokens**: JWT tokens (30-second refresh) + long-lived session tokens <br>**User Data**: Extracted from [`GetClerkClientResponseEntity.kt#L1-116`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/GetClerkClientResponseEntity.kt#L1-116) <br>**Storage**: Encrypted DataStore with `CLERK_AUTH_TOKEN_KEY`                                                                                                                                                                                                                                                                                |
| **Session Persistence**      | **Method**: Automatic via Clerk SDK keychain storage <br>**SDK Implementation**: Internal keychain manager stores tokens with appropriate security attributes <br>**Tokens Stored**: Both JWT tokens and long-lived session tokens persisted across app launches <br>**Security**: Uses iOS Keychain Services with proper accessibility and synchronization settings                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | **Method**: [`PrefsDataStoreManager.kt#L96-107`](https://github.com/suno-ai/app-android/blob/main/common-core-utils/src/main/java/com/suno/android/common_core_utils/environment/PrefsDataStoreManager.kt#L96-107) <br>**Key**: `setLongLivedClerkAuthToken()` and `getLongLivedClerkAuthTokenFlow()`                                                                                                                                                                                                                                                                                                                                                                        |
| **Session Refresh: Short-lived JWT** | **Frequency**: On-demand with intelligent caching (1-minute JWT TTL) <br>**Background Polling**: Every 5 seconds via [`Clerk.swift#L261-274`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Clerk/Clerk.swift#L261-274) `startSessionTokenPolling()` <br>**Cache Strategy**: [`SessionTokenFetcher.swift#L46-78`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Session/SessionTokenFetcher.swift#L46-78) checks cache first, refreshes if token expires within 10 seconds (configurable buffer) <br>**API Call**: `POST /v1/client/sessions/{id}/tokens` <br>**In-Memory Cache**: [`SessionTokensCache.swift#L82-103`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Session/SessionTokenFetcher.swift#L82-103) | **Frequency**: Every 30 seconds via [`AuthManager.kt#L228-236`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt#L228-236) `refreshSunoJwtToken()` <br>**API Call**: `POST /v1/client/sessions/{id}/tokens` <br>**No Background Polling**: Android uses fixed 30-second intervals                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Session Refresh: Long-lived Token** | **Storage**: Keychain via [`ClerkService.swift#L52-63`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Clerk/ClerkService.swift#L52-63) - `saveClientToKeychain()` and `loadClientFromKeychain()` <br>**Device Token Updates**: Long-lived token (device token) is automatically updated via [`ClerkDeviceTokenRequestProcessor.swift#L11-17`](build/clerk-ios/Sources/Clerk/APIClient/RequestProcessors/ClerkDeviceTokenRequestProcessor.swift#L11-17) whenever any API response contains an "Authorization" header - stored in keychain as `clerkDeviceToken` <br>**Refresh Triggers**: Automatic during successful authentication flows (sign-in, sign-up, OAuth completion) <br>**Persistence**: Full `Client` object stored in keychain with session data <br>**Session Restoration**: On app launch, SDK automatically loads from keychain via [`ClerkService.swift#L57-63`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Clerk/ClerkService.swift#L57-63)                                                                                                                                                                                                                       | **Storage**: Encrypted DataStore via [`PrefsDataStoreManager.kt#L96-107`](https://github.com/suno-ai/app-android/blob/main/common-core-utils/src/main/java/com/suno/android/common_core_utils/environment/PrefsDataStoreManager.kt#L96-107) `CLERK_AUTH_TOKEN_KEY` <br>**Refresh Triggers**: Updated from `x-clerk-auth-token` response headers via [`ClerkAuthHeaderInterceptor.kt#L1-51`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/interceptors/ClerkAuthHeaderInterceptor.kt#L1-51) <br>**Persistence**: Long-lived token string stored in encrypted DataStore                                                                                                                                                                                                               |
| **Session Validation**       | **Method**: [`ClerkClient.swift#L466-469`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L466-469) `isLoggedIn()` and `user()` <br>**SDK Implementation**: [`ClientService.swift#L22-25`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/Client/ClientService.swift#L22-25) `get()` method calls `GET /v1/client` <br>**Usage**: Used throughout app for session state checks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | **Method**: [`AuthManager.kt#L154-175`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt#L154-175) `restoreSessionFromClerk()` <br>**API Call**: `GET /v1/client` via [`ClerkService.kt#L75-80`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L75-80)                                                                                                                                                                                                                                                             |
| **Session Restoration**      | **Trigger**: App launch, SDK handles automatically <br>**SDK Implementation**: On app startup, SDK automatically checks keychain for stored tokens and validates session state via `GET /v1/client` <br>**Fallback**: SDK handles re-authentication if needed <br>**Process**: Validates tokens → Restores user state → Handles expired sessions gracefully                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | **Trigger**: App launch via [`AuthManager.kt#L154-175`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt#L154-175) <br>**Validation**: Calls `GET /v1/client` to validate cached tokens <br>**Network-Aware**: Handles offline scenarios gracefully                                                                                                                                                                                                                                                                                                                                                                   |
| **User/Settings Management** | **Phone Numbers**: [`ClerkClient.swift#L342-454`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L342-454) - add, verify, delete <br>**SDK Implementation**: [`PhoneNumberService.swift#L22-31`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/PhoneNumber/PhoneNumberService.swift#L22-31) `create()`, [`PhoneNumberService.swift#L43-51`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/PhoneNumber/PhoneNumberService.swift#L43-51) `prepareVerification()`, [`PhoneNumberService.swift#L54-63`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/PhoneNumber/PhoneNumberService.swift#L54-63) `attemptVerification()`, [`PhoneNumberService.swift#L33-41`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/PhoneNumber/PhoneNumberService.swift#L33-41) `delete()` <br>**Profile Updates**: [`UserService.swift#L23-32`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/User/UserService.swift#L23-32) `update()` calls `PATCH /v1/me` (available but not used) | **Phone Numbers**: Not implemented <br>**Profile Updates**: Not implemented <br>**Limitation**: Android only implements core auth flows                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| **Sign Out**                 | **UI Integration**: [`SettingsV2Screen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureSettingsV2/SettingsV2Screen.swift) <br>**Implementation**: SDK handles token cleanup and session revocation <br>**SDK Process**: Calls `POST /v1/client/sessions/{id}/end` → Clears keychain storage → Updates user state → Triggers UI updates                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | **Implementation**: [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) clears tokens <br>**Storage Cleanup**: Clears DataStore and cached session data                                                                                                                                                                                                                                                                                                                                                                                                                                              |

## Authentication Flows

| Flow                       | iOS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Android                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Phone Number Sign In**   | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L258-304`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) `signInWithPhone()` → [`SignInService.swift#L23-31`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignIn/SignInService.swift#L23-31) `create()` <br>**API Call**: `POST /v1/client/sign_ins` with phone number data <br>**Callback**: Success/error handling in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) with comprehensive error mapping                                                                                                                                                                                                                                                        | **Entry Point**: Mobile app UI flows through [`AuthManager.kt#L1-305`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt#L1-305) <br>**API Call**: [`ClerkService.kt#L49-55`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L49-55) `postSignInPhoneNumber()` → `POST /v1/client/sign_ins` <br>**Callback**: Response handling in [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) with custom error processing                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **Phone Number Sign Up**   | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) (same as sign-in) <br>**SDK Call**: [`ClerkClient.swift#L258-304`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) `signInWithPhone()` → [`SignUpService.swift#L23-34`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignUp/SignUpService.swift#L23-34) `create()` if needed <br>**API Call**: `POST /v1/client/sign_ups` when phone number not found during sign-in <br>**Callback**: Automatic fallback handled in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304)                                                                                                                                                                                                                                     | **Entry Point**: [`ClerkAuthRepository.kt#L1-106`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/auth/ClerkAuthRepository.kt#L1-106) <br>**API Call**: [`ClerkService.kt#L32-38`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L32-38) `postSignUpPhoneNumber()` → `POST /v1/client/sign_ups` <br>**Callback**: Response handling in [`ClerkAuthRepository.kt`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/auth/ClerkAuthRepository.kt)                                                                                                                                                                                                                                                                                                                                                                                                                          |
| **OTP Verification**       | **Entry Point**: [`PhoneSignInScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureSocial/Phone%20Number/PhoneSignInScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L258-304`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) `validatePhoneCode()` → [`SignInService.swift#L63-71`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignIn/SignInService.swift#L63-71) `attemptFirstFactor()` or [`SignUpService.swift#L66-74`](https://github.com/clerk/clerk-ios/blob/main/Sources/Clerk/Models/SignUp/SignUpService.swift#L66-74) `attemptVerification()` <br>**API Call**: `POST /v1/client/sign_ins/{id}/attempt_first_factor` or `POST /v1/client/sign_ups/{id}/attempt_verification` <br>**Callback**: Success/error handling in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L258-304) with session establishment | **Entry Point**: [`ClerkAuthRepository.kt#L1-106`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/auth/ClerkAuthRepository.kt#L1-106) <br>**API Call**: Sign-In: [`ClerkService.kt#L57-64`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L57-64) `attemptVerifyPhoneSignIn()` → `POST /v1/client/sign_ins/{id}/attempt_first_factor` <br>Sign-Up: [`ClerkService.kt#L40-47`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L40-47) `attemptVerifyPhoneSignUp()` → `POST /v1/client/sign_ups/{id}/attempt_verification` <br>**Callback**: Response processing in [`ClerkAuthRepository.kt`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/auth/ClerkAuthRepository.kt) with WhatsApp channel support |
| **Google Sign In**         | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L546-567`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L546-567) `signInWithGoogle()` → Clerk SDK internal OAuth handling <br>**API Call**: `POST /v1/client/sign_ins` with OAuth provider data (handled by SDK) <br>**Callback**: Redirect-based OAuth flow with URL scheme handling in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L546-567)                                                                                                                                                                                                                                                                                                                                                      | **Entry Point**: [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) <br>**API Call**: [`ClerkService.kt#L85-91`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L85-91) `postSignInOauth()` → `POST /v1/client/sign_ins` + [`ClerkService.kt#L93-98`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L93-98) `getSignInOauth()` → `GET /v1/client/sign_ins/{id}` <br>**Callback**: Deep link handling in [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) with `suno://` redirect URIs                                                                                                                                                                                                                                                    |
| **Apple Sign In**          | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L307-339`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L307-339) `signInWithApple()` → Uses `ASAuthorizationAppleIDProvider` <br>**API Call**: `POST /v1/client/sign_ins` with Apple ID token (handled by SDK) <br>**Callback**: Apple authorization delegate callbacks in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L307-339) with token exchange                                                                                                                                                                                                                                                                                                                                                | **Entry Point**: [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) <br>**API Call**: [`ClerkService.kt#L85-91`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L85-91) `postSignInOauth()` → `POST /v1/client/sign_ins` + [`ClerkService.kt#L93-98`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L93-98) `getSignInOauth()` → `GET /v1/client/sign_ins/{id}` <br>**Callback**: Deep link handling in [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) with `suno://` redirect URIs                                                                                                                                                                                                                                                    |
| **Microsoft Sign In**      | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L568-590`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L568-590) `signInWithMicrosoft()` → Clerk SDK internal OAuth handling <br>**API Call**: `POST /v1/client/sign_ins` with Microsoft OAuth provider data (handled by SDK) <br>**Callback**: Redirect-based OAuth flow with URL scheme handling in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L568-590)                                                                                                                                                                                                                                                                                                                                         | **Entry Point**: [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) <br>**API Call**: [`ClerkService.kt#L85-91`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L85-91) `postSignInOauth()` → `POST /v1/client/sign_ins` + [`ClerkService.kt#L93-98`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L93-98) `getSignInOauth()` → `GET /v1/client/sign_ins/{id}` <br>**Callback**: Deep link handling in [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) with `suno://` redirect URIs                                                                                                                                                                                                                                                    |
| **Discord Sign In**        | **Entry Point**: [`SignUpScreen.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/FeatureOnboarding/SignUpScreen.swift) <br>**SDK Call**: [`ClerkClient.swift#L591-613`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L591-613) `signInWithDiscord()` → Clerk SDK internal OAuth handling <br>**API Call**: `POST /v1/client/sign_ins` with Discord OAuth provider data (handled by SDK) <br>**Callback**: Redirect-based OAuth flow with URL scheme handling in [`ClerkClient.swift`](https://github.com/suno-ai/app-ios/blob/develop/Sources/ClerkClient/ClerkClient.swift#L591-613)                                                                                                                                                                                                                                                                                                                                             | **Entry Point**: [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) <br>**API Call**: [`ClerkService.kt#L85-91`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L85-91) `postSignInOauth()` → `POST /v1/client/sign_ins` + [`ClerkService.kt#L93-98`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/clerk/ClerkService.kt#L93-98) `getSignInOauth()` → `GET /v1/client/sign_ins/{id}` <br>**Callback**: Deep link handling in [`AuthManager.kt`](https://github.com/suno-ai/app-android/blob/main/app/src/main/java/com/suno/android/auth/AuthManager.kt) with `suno://` redirect URIs                                                                                                                                                                                                                                                    |
| **App Force Update Check** | **Entry Point**: [`APIClient.swift#L544-548`](https://github.com/suno-ai/app-ios/blob/develop/Sources/APIClient/APIClient.swift#L544-548) `manifest()` function <br>**API Call**: `POST /api/app_version_update` with app metadata (`app_name: "Suno", platform: "ios"`) <br>**Callback**: Returns `Manifest` object with version requirements and update policy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Entry Point**: [`AppVersionManager.kt#L20-30`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/app_version/AppVersionManager.kt#L20-30) `checkAppVersionUpdateFlow()` <br>**API Call**: [`AppVersionUpdateService.kt#L11-14`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/session/AppVersionUpdateService.kt#L11-14) `POST /app_version_update/` with app metadata <br>**Callback**: Returns `AppVersionUpdateResponse` with update requirements via Flow                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| **Session Info Retrieval** | **Entry Point**: [`APIClientV2.swift#L609`](https://github.com/suno-ai/app-ios/blob/develop/Sources/APIClient/APIClientV2.swift#L609) `me()` function <br>**API Call**: `GET /api/session` returns current session state and user information <br>**Callback**: Returns `PathsApiSession.Session.GetResponse` with `LoggedInSessionResponse` or `UnauthenticatedSessionResponse`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Entry Point**: [`UserSessionRepository.kt#L29-37`](https://github.com/suno-ai/app-android/blob/main/common-data/src/main/java/com/suno/android/common_data/user/UserSessionRepository.kt#L29-37) `refreshUserSessionState()` <br>**API Call**: [`SessionConfigService.kt#L7-8`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/session/SessionConfigService.kt#L7-8) `GET /session/` → returns session configuration <br>**Callback**: Returns `SessionConfigurationResponse` with user data, feature flags, model information, and user roles via [`SessionConfigurationResponse.kt`](https://github.com/suno-ai/app-android/blob/main/common-networking/src/main/java/com/suno/android/common_networking/remote/session/SessionConfigurationResponse.kt)                                                                                                                                                                                                          |
