CgsAuth

interface CgsAuth

Opening a session, and choosing which profile it runs as.

Obtained from CGS.auth. The SDK does not sign users in itself: you authenticate them however you already do, get a host token from your backend, and exchange it here for an SDK session.

when (val result = CGS.auth().authenticate(hostToken)) {
is CgsResult.Success -> CGS.auth().setCurrentProfile(profileId)
is CgsResult.Failure -> showError(result.cgsError)
}

The session is persisted and refreshed on its own — authenticate once, not on every launch. Check state at startup to know whether you still have one.

Properties

Link copied to clipboard
abstract val state: StateFlow<AuthState>

Where the session stands, now and on every change.

Functions

Link copied to clipboard
abstract suspend fun authenticate(hostToken: String): CgsResult<Unit>

Exchanges one of your own tokens for an SDK session, unlocking the content APIs.

Link copied to clipboard
abstract suspend fun clearSession()

Ends the session and erases what it left on the device — tokens, the active profile, and the cached content that was scoped to it.

Link copied to clipboard
abstract fun setCurrentProfile(profileId: String)

Chooses which profile the session reads as.