---
title: "sdk/android"
description: "Kotlin SDK for Android using Chrome Custom Tabs, PKCE S256 authorization code flow, and Keystore-backed EncryptedSharedPreferences token storage."
locale: "en"
---

> Documentation Index
> Fetch the relevant documentation index at: https://vonvon.id/sdks/llms.txt
> Use this file to discover all available pages before exploring further.

# sdk/android

## Status

Package status is **Implemented and verified locally**. The JVM unit-test suite passes and covers PKCE, state and nonce handling, guest capability, and storage contracts. EncryptedSharedPreferences, Chrome Custom Tabs, App Links, and a real IdP round-trip still require a device or emulator. This page documents implemented behavior; it is not a production-readiness claim.

Registry status: UNPUBLISHED. Install this SDK only from the repository source checkout; do not use an external package registry.

## Requirements

- Android API 26+ (Android 8.0)
- Kotlin 1.9+ and AndroidX

## Installation

Add the dependency to your app module's build.gradle.kts:

```kotlin
// settings.gradle.kts
includeBuild("../vonvon/sdk/android")

// app/build.gradle.kts
dependencies {
implementation("dev.vonvon:vonvon-android:0.1.0-alpha.0")
}
```

## Manifest setup

Register a callback Activity with an intent-filter. App Links (HTTPS scheme with autoVerify) are recommended over custom schemes:

```xml
<!-- AndroidManifest.xml -->
<activity android:name=".AuthCallbackActivity" android:exported="true">
<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="https"
          android:host="yourapp.example.com"
          android:pathPrefix="/auth/callback" />
</intent-filter>
</activity>
```

## Quick start

```kotlin
import dev.vonvon.sdk.Vonvon
import dev.vonvon.sdk.model.VonvonConfig

// 1. Initialize in Application.onCreate. offline_access is rejected until DPoP is implemented.
Vonvon.configure(
context = this,
config = VonvonConfig(
    issuer = "https://vonvon.id",
    clientId = "your_client_id",
    redirectUri = "https://yourapp.example.com/auth/callback",
    scopes = listOf("openid", "profile", "email"),
)
)

// 2. Sign in (opens Chrome Custom Tabs)
lifecycleScope.launch { Vonvon.signIn(requireContext()) }

// 3. Handle redirect in AuthCallbackActivity
val session = Vonvon.handleRedirect(intent.data.toString())

// 4. Read the current unexpired session. Expiry requires reauthorization.
val session = Vonvon.getSession()

// 5. Get the current unexpired access token.
val token = Vonvon.getAccessToken()

// 6. Clear local state and optionally open end_session.
Vonvon.signOut(context = this, openEndSession = true)
```

## Core API

| Method | Signature |
| --- | --- |
| `configure` | `fun configure(context: Context, config: VonvonConfig)` |
| `signIn` | `suspend fun signIn(context: Context, options: SignInOptions? = null)` |
| `handleRedirect` | `suspend fun handleRedirect(url: String): VonvonSession` |
| `getSession` | `suspend fun getSession(): VonvonSession?` |
| `getAccessToken` | `suspend fun getAccessToken(options: GetAccessTokenOptions? = null): String` |
| `signOut` | `suspend fun signOut(context: Context? = null, openEndSession: Boolean = false)` |
| `setTokenStorage` | `fun setTokenStorage(adapter: TokenStorageAdapter)` |

## Error types

All SDK errors are subtypes of the sealed class VonvonException:

| Subclass | Trigger |
| --- | --- |
| `NotConfigured` | configure() was not called |
| `UserCancelled` | User closed Custom Tabs without completing |
| `StateMismatch` | OAuth state mismatch — possible CSRF |
| `TokenExchangeFailed` | Token endpoint returned an error |
| `TokenValidationFailed` | ID token signature or claims validation failed |
| `NoSession` | Session method called while signed out |

## Security

- Public client — no client secret stored or transmitted.
- PKCE S256 only. Server rejects plain challenge method.
- EncryptedSharedPreferences backed by Android Keystore (AES-256-GCM) protects the token store at rest.
- Random OAuth state generated per request; validated on redirect to prevent CSRF.

## Known limitations

- JWKS-backed ID token verification is implemented and locally unit-tested. Android device or emulator and real IdP validation are still required before L4 support.
- No mechanism to detect when the user closes Custom Tabs without completing authorization.
- Single-account only — the storage layer uses fixed keys.

Source: https://vonvon.id/sdks/android/index.mdx
