Skip to main content

API reference

The public surface of

io.thunderid:android, as documented in its reference pages.

componentSignIn

The `SignIn` composable renders a full app-native sign-in form. It drives the Flow Execution API loop automatically: initiating the flow, presenting the server-defined inputs and actions on each step, and completing when the user is authenticated. `SignIn` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
applicationIdrequired
String

The Application ID from your ThunderID application settings. Identifies which sign-in flow to execute.

modifieroptional
Modifier

Compose modifier applied to the form container.

onCompleteoptional
(() -> Unit)?

Called when authentication completes successfully.

onErroroptional
((String) -> Unit)?

Called with an error message when a flow step fails.

Example
import dev.thunderid.compose.components.presentation.auth.SignIn

@Composable
fun AuthView(applicationId: String) {
    SignIn(
        applicationId = applicationId,
        modifier = Modifier.fillMaxWidth().padding(16.dp)
    )
}
componentSignInButton

The `SignInButton` composable renders a pre-styled button that calls an `onClick` lambda when tapped. It does not initiate the sign-in flow itself. Your `onClick` handler opens the sign-in UI (e.g., showing a `SignIn` form or launching the redirect URL). `SignInButton` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
onClickrequired
() -> Unit

Called when the button is tapped.

modifieroptional
Modifier

Compose modifier.

Example
import dev.thunderid.compose.components.actions.SignInButton

@Composable
fun LandingView() {
    var showSignIn by remember { mutableStateOf(false) }

    SignInButton(onClick = { showSignIn = true })

    if (showSignIn) {
        SignIn(applicationId = "<your-application-id>")
    }
}
componentSignOutButton

The `SignOutButton` composable renders a pre-styled button that calls `ThunderIDClient.signOut()`, then calls `ThunderIDState.refresh()` to update the reactive auth state. It disables itself automatically while the sign-out operation is in progress. `SignOutButton` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
modifieroptional
Modifier

Compose modifier applied to the button.

onSignOutCompleteoptional
(() -> Unit)?

Called after sign-out completes and `ThunderIDState` has been refreshed.

Example
import dev.thunderid.compose.components.actions.SignOutButton

@Composable
fun HomeView() {
    Column {
        Text("You are signed in.")
        SignOutButton()
    }
}
componentSignUp

The `SignUp` composable renders a full app-native registration form. It drives the Flow Execution API loop automatically: initiating the registration flow, presenting the server-defined inputs and actions on each step, and completing when the user is registered and authenticated. `SignUp` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
modifieroptional
Modifier

Compose modifier applied to the form container.

onCompleteoptional
(() -> Unit)?

Called when registration completes successfully.

onErroroptional
((String) -> Unit)?

Called with an error message when a flow step fails.

Example
import dev.thunderid.compose.components.presentation.auth.SignUp

@Composable
fun RegisterView() {
    SignUp(modifier = Modifier.fillMaxWidth().padding(16.dp))
}
componentSignedIn

The `SignedIn` composable conditionally renders its content only when the user is authenticated. It reads the current sign-in state from `LocalThunderID` and displays protected UI for signed-in users, while rendering optional fallback content (or nothing) when the user is not authenticated. `SignedIn` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
fallbackoptional
(@Composable () -> Unit)?

The composable to render when the user is not authenticated. Defaults to nothing.

contentrequired
@Composable () -> Unit

The composable to render when the user is authenticated.

Example
import dev.thunderid.compose.components.guards.SignedIn

@Composable
fun ContentView() {
    SignedIn {
        Text("You are signed in.")
    }
}
componentSignedOut

The `SignedOut` composable conditionally renders its content only when the user is **not** authenticated. It is the counterpart to `SignedIn`. `SignedOut` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
fallbackoptional
(@Composable () -> Unit)?

The composable to render when the user is authenticated. Defaults to nothing.

contentrequired
@Composable () -> Unit

The composable to render when the user is not authenticated.

Example
import dev.thunderid.compose.components.guards.SignedOut

@Composable
fun ContentView() {
    SignedOut {
        Text("Please sign in to continue.")
    }
}
componentUserProfile

The `UserProfile` composable renders an editable profile form. It loads the user's current profile from `/scim2/Me` when it first composes, presents editable fields for `displayName` and `phoneNumbers`, and saves changes via `ThunderIDClient.updateUserProfile`. `UserProfile` requires `ThunderIDProvider` in its ancestor composable hierarchy.

Parameters
modifieroptional
Modifier

Compose modifier applied to the form container.

onSavedoptional
(() -> Unit)?

Called after a successful profile save.

onErroroptional
(() -> Unit)?

Called when a load or save operation fails.

Example
import dev.thunderid.compose.components.presentation.user.UserProfile

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ProfileSheet(onDismiss: () -> Unit) {
    ModalBottomSheet(onDismissRequest = onDismiss) {
        UserProfile(
            modifier = Modifier.fillMaxWidth().padding(24.dp),
            onSaved = onDismiss
        )
    }
}
functionConfiguration

`ThunderIDConfig` is the configuration data class passed to `ThunderIDClient.initialize(config, storage)` and to the `ThunderIDProvider` composable.

Parameters
baseUrl
String

**Required.** Your ThunderID instance URL. Must use HTTPS (e.g., `https://localhost:8090`).

clientId
String?

The Client ID from your ThunderID application. Required for redirect-based authentication and token operations.

scopes
List

OAuth 2.0 scopes to request. Include `"profile"` and `"email"` to receive user identity claims.

afterSignInUrl
String?

The redirect URI to return to after sign-in. Must match an **Allowed Redirect URI** registered in the console.

afterSignOutUrl
String?

The redirect URI to return to after sign-out. Must match an **Allowed Post-Logout Redirect URI** in the console.

signInUrl
String?

Override the sign-in URL. Defaults to the ThunderID hosted sign-in page.

signUpUrl
String?

Override the sign-up URL.

clientSecret
String?

Client secret for confidential clients. Do not include this in a shipped Android app.

signInOptions
Map

Additional query parameters appended to the authorization URL on sign-in.

signOutOptions
Map

Additional parameters sent with the sign-out request.

signUpOptions
Map

Additional parameters sent with the sign-up request.

applicationId
String?

The Application ID used for app-native (embedded) sign-in flows via the Flow Execution API.

organizationHandle
String?

The organization handle for multi-tenant deployments.

tokenValidation
TokenValidationConfig

Controls ID token validation behavior.

storage
StorageAdapter?

Custom token storage backend. Defaults to `EncryptedStorageAdapter`.

instanceId
Int?

Identifies the SDK instance when running multiple instances in one process.

Example
import dev.thunderid.android.ThunderIDConfig

val config = ThunderIDConfig(
    baseUrl = "https://localhost:8090",
    clientId = "<your-client-id>",
    scopes = listOf("openid", "profile", "email"),
    afterSignInUrl = "dev.thunderid.app://callback",
    afterSignOutUrl = "dev.thunderid.app://logout",
    applicationId = "<your-application-id>"
)
functionThunderIDClient

`ThunderIDClient` is the core authentication client in the `dev.thunderid:android` library. It manages the full authentication lifecycle: initialization, sign-in (both app-native and redirect-based), session, token management, and user profile operations. When you use the `dev.thunderid:compose` library, a `ThunderIDClient` instance is created and managed automatically. You can access it via `LocalThunderID.current.client` from any composable.

Example
import dev.thunderid.android.ThunderIDClient
import dev.thunderid.android.ThunderIDConfig

val client = ThunderIDClient()

client.initialize(
    config = ThunderIDConfig(
        baseUrl = "https://localhost:8090",
        clientId = "<your-client-id>",
        scopes = listOf("openid", "profile", "email"),
        afterSignInUrl = "dev.thunderid.app://callback",
        afterSignOutUrl = "dev.thunderid.app://logout"
    )
)
functionThunderIDState

`ThunderIDState` is the reactive authentication state class provided by the `dev.thunderid:compose` library. It holds the current user, loading state, and initialization status, and exposes the underlying `ThunderIDClient` for direct API calls. `ThunderIDState` is provided via `LocalThunderID`, a `CompositionLocal` injected by `ThunderIDProvider`. Any composable in the hierarchy can read it using `LocalThunderID.current`.

Example
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import dev.thunderid.android.ThunderIDConfig
import dev.thunderid.compose.ThunderIDProvider

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ThunderIDProvider(
                config = ThunderIDConfig(
                    baseUrl = "https://localhost:8090",
                    clientId = "<your-client-id>",
                    afterSignInUrl = "dev.thunderid.app://callback",
                    afterSignOutUrl = "dev.thunderid.app://logout"
                )
            ) {
                AppContent()
            }
        }
    }
}
ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.