Skip to content

l8p8/loop8-auth-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loop8 Auth Android — Sample App

Example app demonstrating how to integrate the Loop8 Auth Android SDK using OpenID Connect (Authorization Code + PKCE). The SDK opens the Loop8 consumer app, completes the OAuth exchange, validates the ID token (RS256 + JWKS), and stores it encrypted on-device.

Add the dependency

dependencies {
    implementation("io.github.l8p8:auth:1.0")
}

Requirements

  • Min SDK: 24
  • Loop8 app (com.l8p8.l8p8) must be installed for the interactive flow; otherwise the SDK opens the Play Store listing.

Manifest (host app)

Declare package visibility for Android 11+:

<queries>
    <package android:name="com.l8p8.l8p8" />
</queries>

Initialise

Call from Application.onCreate or before the first sign-in:

Loop8Auth.init(
    context = this,
    config = AuthConfig(
        clientId = "YOUR_CLIENT_ID",
        debug = BuildConfig.DEBUG,   // enables verbose OkHttp logs
    ),
)

Sign in

The only way to start the sign-in flow is via Loop8SignInButton. There is no programmatic login entry point by design.

import com.loop8.auth.ui.Loop8SignInButton

Loop8SignInButton()

The button handles loading state internally. Observe Loop8Auth.authState to react to results:

// Compose
val state by Loop8Auth.authState.collectAsState()
when (state) {
    is AuthLoginState.InProgress -> { /* loading */ }
    is AuthLoginState.Success    -> { val idToken = state.idToken }
    is AuthLoginState.Error      -> {
        when (state.reason) {
            is AuthError.Denied        -> { /* age verification failed */ }
            is AuthError.UserCancelled -> { /* user dismissed */ }
            else                       -> { /* other error */ }
        }
    }
    null -> { /* idle / logged out */ }
}

// Coroutine
Loop8Auth.authState.collect { state -> … }

Sign out

Loop8Auth.logout()

Clears the encrypted token and resets authState to null.

Public API

Package Contents
com.loop8.auth.api Loop8Auth, AuthManager, AuthConfig, AuthLoginState, AuthResult, IdTokenClaims, AuthError, AuthLogger
com.loop8.auth.ui Loop8SignInButton

All internal packages are obfuscated by R8 and not part of the public contract.

Sample app

Run the project. Demonstrates MVI setup with MainViewModel mapping Loop8Auth.authState to a UiState, rendered by a pure Compose screen.

License

See repository licensing terms.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors