Skip to main content

Use AI to integrate Auth0

If you use an AI coding assistant like Claude Code, Cursor, or GitHub Copilot, you can add Auth0 authentication automatically in minutes using agent skills.Install:
Then ask your AI assistant:
Your AI assistant automatically creates your Auth0 application, fetches credentials, adds the Auth0 Kotlin Multiplatform SDK dependency, configures the Android manifest placeholders and iOS URL scheme, and implements login/logout flows. Read the full agent skills documentation.
Use this quickstart with Kotlin Multiplatform 2.0+, with Android SDK 24+, (Android 7.0), and iOS 14+. The Auth0 Kotlin Multiplatform SDK is currently in 1.0.0-beta.0. Pin this version explicitly, as the API may change before the stable release. You need Android Studio (Ladybug or newer) and, for the iOS target, Xcode 15+ on macOS.

Get Started

Use this quickstart to configure your Kotlin Multiplatform app for end users to log in and out through Auth0 Universal Login, persist tokens securely, and display user profiles — all from shared Kotlin code running on both Android and iOS.
1

Create a new Kotlin Multiplatform project

If you already have a Kotlin Multiplatform project, skip to the next step.Create a new Kotlin Multiplatform project with a shared Compose UI using the JetBrains Kotlin Multiplatform wizard (select Android and iOS, and share the UI with Compose Multiplatform), or the Kotlin Multiplatform plugin in Android Studio.This produces the standard layout referenced throughout this guide:
This guide uses com.example.app as the application ID / bundle identifier. Replace this placeholder with your own since it becomes part of your Auth0 callback URLs.
2

Add the Auth0 SDK via Gradle

Add the Auth0 Kotlin Multiplatform SDK to the commonMain source set of your shared module. The library is published to Maven Central, so no extra repository configuration is required.Update composeApp/build.gradle.kts:
composeApp/build.gradle.kts
The umbrella auth0 artifact pulls in everything you need. For a smaller footprint, you can depend on the following individual modules instead: auth0-core, auth0-webauth, auth0-authentication, auth0-credentials.
3

Setup your Auth0 App

Create a Native application in Auth0 and register the platform callback and logout URLs for both Android and iOS.
  1. Navigate to the Auth0 Dashboard.
  2. Select Applications > Applications > Create Application.
  3. In the popup, enter a name for your app, select Native as the app type, and choose Create.
  4. Switch to the Settings tab on the Application Details page and copy the Domain and Client ID. You need to add them to your code in a later step.
Still on the Settings tab, configure the following URLs. The callback format is scheme-specific per platform, so register one entry for Android and one for iOS:Allowed Callback URLs:
Allowed Logout URLs:
Replace {yourDomain} with your actual Auth0 domain (e.g., dev-abc123.us.auth0.com) and com.example.app with your application ID / bundle identifier.
Allowed Callback URLs ensure end users are safely returned to your application after authentication. Without a matching URL, the login process will fail. Allowed Logout URLs ensure users are redirected back to your app after signing out.The callback format embeds your package/bundle identifier: SCHEME://YOUR_DOMAIN/android/APPLICATION_ID/callback for Android and SCHEME://YOUR_DOMAIN/ios/BUNDLE_ID/callback for iOS. By default the scheme equals your application ID / bundle identifier.
Important: Ensure the package/bundle name in your callback URLs matches your applicationId (Android) and bundle identifier (iOS) exactly. If authentication fails, verify these values are identical.
4

Register the callback scheme on each platform

The SDK ships a RedirectActivity (Android, merged automatically) and uses ASWebAuthenticationSession (iOS) to catch the callback. You only need to declare the URL scheme on each platform.Android: Add the manifest placeholders to your Android build file. The SDK’s RedirectActivity reads these values:
composeApp/build.gradle.kts
Also ensure your AndroidManifest.xml requests the Internet permission:
composeApp/src/androidMain/AndroidManifest.xml
iOS: Register the URL scheme in iosApp/iosApp/Info.plist (or via Xcode → target → InfoURL Types):
iosApp/iosApp/Info.plist
5

Initialize the Auth0 SDK

In your shared commonMain source set, create the Auth0 client once and reuse it. It holds the transport shared by web auth, the Authentication API, and the credentials manager.Create composeApp/src/commonMain/kotlin/Auth0Config.kt:
composeApp/src/commonMain/kotlin/Auth0Config.kt
For production, avoid hard-coding credentials in source. The sample app reads auth0.domain and auth0.clientId from local.properties and exposes them via generated config. The Domain and Client ID both come from Application Settings in the Auth0 Dashboard. The domain must not include the https:// scheme.
6

Implement Login and Logout

Every Auth0 Kotlin Multiplatform method is a coroutine suspend function that returns a Result<Success, Error> — no exceptions are thrown for domain errors. Wrap the calls in a ViewModel so your Compose UI can observe the state.Create composeApp/src/commonMain/kotlin/AuthViewModel.kt:
composeApp/src/commonMain/kotlin/AuthViewModel.kt
Wire the view model into a Compose screen shared across both platforms:
composeApp/src/commonMain/kotlin/App.kt
7

Show the user profile

After login, call the Authentication API’s userInfo with the access token to retrieve the authenticated user’s profile.
composeApp/src/commonMain/kotlin/AuthViewModel.kt
On app launch, you can skip the login screen if valid credentials already exist: credentialsManager.hasValidCredentials() returns true when a stored, non-expired session is available. Use credentialsManager.getCredentials() to retrieve a valid access token, and renew the access token with the refresh token automatically when needed.
8

Run your app

Build and launch on each target:
Expected flow:
  1. App launches with a “Log In” button.
  2. Tap “Log In” → the system browser opens the Auth0 Universal Login page → complete login.
  3. Control returns to the app automatically and the button switches to “Log Out”.
  4. Success!
CheckpointYou now have a Compose Multiplatform app with Auth0 login, logout, secure token storage, and user profile retrieval — sharing all authentication logic between Android and iOS.

Troubleshooting & Advanced

Cause: The callback URL the SDK generates isn’t listed in your Auth0 application, or the scheme/package don’t match.Fix: Confirm Allowed Callback URLs in Application Settings exactly matches the platform format — SCHEME://YOUR_DOMAIN/android/APPLICATION_ID/callback for Android and SCHEME://YOUR_DOMAIN/ios/BUNDLE_ID/callback for iOS. The SCHEME (default: your application ID) and package/bundle must be identical to your project’s values. URLs are case-sensitive and the scheme must be lowercase.
Cause: The callback scheme isn’t declared on the platform, so the OS can’t route the redirect back to your app.Fix: On Android, verify manifestPlaceholders["auth0Scheme"] and ["auth0Domain"] are set in composeApp/build.gradle.kts and run a clean build. On iOS, verify the CFBundleURLSchemes entry in Info.plist matches your bundle identifier.
Cause: The device can’t reach your Auth0 tenant, or a request times out.Fix: Confirm domain in Auth0Account is your tenant domain without the https:// scheme (e.g., your-tenant.us.auth0.com). On a physical device, ensure it has network access. You can raise the timeouts via the NetworkingConfiguration passed to Auth0Account.
Cause: No refresh token is issued, so expired credentials aren’t renewed.Fix: Universal Login requests the offline_access scope by default (which returns a refresh token). If you override scope in LoginOptions, include offline_access, and enable Refresh Token Rotation for the application in the Auth0 Dashboard.
Cause: The auth0Domain / auth0Scheme manifest placeholders are missing, so the SDK’s merged RedirectActivity has no value to bind to.Fix: Ensure both placeholders are defined in the defaultConfig block of composeApp/build.gradle.kts. If you use multiple build flavors, define them in each flavor.
Check for stored credentials before showing the login screen so returning users skip Universal Login:
Request an audience so Auth0 issues an access token for your API:
Log the user out of the upstream identity provider as well as Auth0:

Next steps