Getting Started
warning
The Android Platform SDK is not yet released. This page describes the planned integration experience.
Initialise the SDK
Initialise KapeClient once in your Application class:
import com.kape.sdk.KapeClient
import com.kape.sdk.KapeConfiguration
class MyApplication : Application() {
val kape: KapeClient by lazy {
KapeClient(
context = this,
configuration = KapeConfiguration(
clientId = "your-client-id",
environment = KapeEnvironment.PRODUCTION
)
)
}
}
Authenticate
// OpenID Connect
kape.auth.loginWithOpenID(activity)
// Opaque token (white-label)
kape.auth.loginWithOpaqueToken(userId = "uid", token = "token")
Fetch Server Locations
viewModelScope.launch {
val locations = kape.vpn.locations()
}
Observe Authentication State
kape.auth.state.collect { state ->
when (state) {
is AuthState.Authenticated -> { /* show home */ }
is AuthState.Unauthenticated -> { /* show login */ }
}
}