Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Authentication Overview

The SDK supports two kinds of credential: a person’s sign-in at Aduki ID, and a static API key for headless clients.

Credentials

PropertyInteractive sign-inAPI key
Useapps with human usersworkers, tests, daemons
Credentialsaddress + password + second factor, at Aduki IDan opaque key issued at Aduki Mail
HTTP headerAuthorization: Bearer <access token> (DPoP <token> when bound)Authorization: Key <key>
Lifetime10-minute access token (EdDSA JWT per audience), single-use rotating refresh tokenuntil revoked at the server
Renewalautomatic on 401none
Sign-outDELETE /v1/sessions/{hex} at Aduki IDrevoke the key

Tokens and sessions are held in memory (client.session). The SDK does not write them to disk; persisting the refresh token between launches is up to the app (restore it with Id.adopt or session.update).

In this section

Session lifecycle

stateDiagram-v2
    [*] --> Unauthenticated
    Unauthenticated --> ActiveSession: Aduki.login(handle, password, code)
    Unauthenticated --> Unauthenticated: 401 / error
    ActiveSession --> ActiveSession: 401 or refresh(): tokens rotated
    ActiveSession --> Unauthenticated: refresh refused (sign in again)
    ActiveSession --> Unauthenticated: logout()

Core types

data class Tokens(
    val token: String = "",    // access token (JWT)
    val refresh: String = "",  // single-use refresh token
    val expires: String = "",  // access-token lifetime in seconds
    val session: String = ""   // Aduki ID session hex, used to sign out
)

data class Identity(
    val user: String = "",
    val tenant: String = "",
    val owner: Boolean = false,
    val scopes: List<String> = emptyList(),  // only if the server returns them
    val tier: String = ""                    // only if the server returns it
)

Identity is read from mail’s GET /v1/user by client.me().