# Android SDK

An Android library for minSdk 26. Dependencies: AndroidX Browser and Credentials, kotlinx-coroutines and kotlinx-serialization.

## Install

```kotlin
implementation("com.ohauthcat:ohauthcat-android:0.0.2")
```

- Create an `OhAuthCatClient` with a `Configuration` (login origin, publishable key, redirect URI), a `CustomTabsAuthenticator(activity)` and a `KeystoreTokenStore(context)`, and set `manifestPlaceholders["ohauthcatRedirectScheme"]` in Gradle.
- `signIn()` opens the hosted login in a Custom Tab with PKCE (S256), `state` and `nonce`; the SDK's `RedirectActivity` receives the callback. Call `onResumeWithoutRedirect()` from your activity's `onResume` while a sign-in is pending, so a closed tab becomes `Cancelled`.
- Tokens are encrypted with an AES-256-GCM key held in the Android Keystore. Exclude the `com.ohauthcat.sdk` preferences file from backups.
- `accessToken()` refreshes once for all callers; `signOut()` always clears locally; `switchOrganization(id)` runs the hosted login again.
- Passkeys in the app go through `Passkeys(backend, CredentialManagerPasskeys(activity))`.
- Errors are `OhAuthCatException` subclasses with the catalogue code.
