SDK
Android SDK (Kotlin)
Native Android authentication with OAuth 2.0 PKCE, encrypted storage, and biometric login.
Key Features
OAuth 2.0 Authorization Code + PKCE
EncryptedSharedPreferences token storage
BiometricPrompt (fingerprint / face)
Automatic token refresh
Chrome Custom Tab login
Jetpack Compose support
Kotlin Coroutines & Flow
Session management
Requirements
- Android API 24+ (Android 7.0)
- Kotlin 1.8+
- Android Studio Hedgehog+
Installation
Add the dependency to your module-level build.gradle.
// build.gradle.kts (Module)
dependencies {
implementation("com.idenplane:idenplane-android:1.0.0")
}
// settings.gradle.kts — add repository if needed
dependencyResolutionManagement {
repositories {
mavenCentral()
}
} Configuration
Initialize the Idenplane client using the builder pattern.
import com.idenplane.sdk.IdenplaneClient
val idenplane = IdenplaneClient.Builder()
.serverUrl("https://auth.example.com")
.realm("my-realm")
.clientId("my-android-app")
.redirectUri("myapp://callback")
.build() Login with PKCE
Launch the OAuth 2.0 Authorization Code + PKCE flow using a Chrome Custom Tab.
// Launch login (opens Chrome Custom Tab)
idenplane.login(activity) { result ->
when (result) {
is AuthResult.Success -> {
val token = result.accessToken
val user = result.userInfo
println("Logged in as ${user.name}")
}
is AuthResult.Error -> {
println("Login failed: ${result.message}")
}
is AuthResult.Cancelled -> {
println("User cancelled login")
}
}
} Biometric Authentication
Use BiometricPrompt for fingerprint / face unlock re-authentication.
// Enable biometric login (stores tokens in EncryptedSharedPreferences)
idenplane.enableBiometrics(activity)
// Login with biometrics
idenplane.loginWithBiometrics(activity) { result ->
if (result is AuthResult.Success) {
println("Biometric login successful")
}
}
// Check availability
val available = idenplane.isBiometricsAvailable(context) User Info
Retrieve the authenticated user profile.
val user = idenplane.getUserInfo()
println(user.name) // "John Doe"
println(user.email) // "[email protected]"
println(user.roles) // ["admin", "user"]
// Or use Kotlin coroutines
lifecycleScope.launch {
val user = idenplane.getUserInfoAsync()
} Token Management
Tokens are stored in EncryptedSharedPreferences and refreshed automatically.
// Automatic refresh before expiry
val token = idenplane.accessToken
// Manual refresh
idenplane.refreshToken { result ->
if (result is AuthResult.Success) {
val newToken = result.accessToken
}
}
// Check authentication state
if (idenplane.isAuthenticated) { /* ... */ } Logout
Logout clears stored tokens and revokes the session on the server.
idenplane.logout { result ->
// Tokens cleared from EncryptedSharedPreferences
// Session revoked on server
println("Logged out successfully")
} Jetpack Compose Integration
Use the SDK with Jetpack Compose.
@Composable
fun AuthScreen(idenplane: IdenplaneClient) {
val isAuthenticated by idenplane.isAuthenticatedState.collectAsState()
if (isAuthenticated) {
val user by idenplane.userState.collectAsState()
Column {
Text("Welcome, ${user?.name}")
Button(onClick = { idenplane.logout {} }) {
Text("Logout")
}
}
} else {
val context = LocalContext.current
Button(onClick = { idenplane.login(context as Activity) {} }) {
Text("Sign In")
}
}
}