oauth-kmp
0.1.2indexedImplements OAuth PKCE flow for Android and iOS, facilitating secure authentication by managing URL schemes, OAuth clients, and handling sign-in callbacks across both platforms.
3
Stars
—
Used by
dependents
—
Health
/ 100
Implements OAuth PKCE flow for Android and iOS, facilitating secure authentication by managing URL schemes, OAuth clients, and handling sign-in callbacks across both platforms.
A Kotlin Multiplatform library for Android and iOS that provides an OAuth PKCE flow implementation.
⚠️ This is a work-in-progress library that was recently extracted from a reference project. The API is subject to change. Detailed installation instructions need to be written.
In general, the key steps for using this library are:
exampleapp://)client_id values.PKCEFlow.authState to be notified when the sign in process completes.startSignIn
onNewIntent and handle the auth callback. Something like:override fun onNewIntent(intent: Intent) {
// Ensure the callbackUrl is for OAuth before processing it as such.
if (intent.data?.toString()?.startsWith(PKCE_REDIRECT_URL) == true) {
pkceFlow.continueSignInWithCallbackOrError(dataUrl, null)
}
}
AuthenticationServices.authState.state is FINISHED, either extract/save the tokens and proceed with sign-in, or present the user with an error message. See, e.g. https://github.com/collectiveidea/oauth-kmp/blob/main/oauth-core/src/commonTest/kotlin/com/collectiveidea/oauth/PKCEFlowTest.kt#L186Surfaced from shared tags and platforms — no rankings paid for.