Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkOS Android SDK

The WorkOS Android SDK provides access to AuthKit from Kotlin applications. Use PublicClient to sign users in with PKCE using only your application's client ID.

Never include a WorkOS API key or client secret in an Android app. Anything shipped in an APK is extractable. API keys belong only in trusted server environments.

Requirements

  • Android 8.0 (API level 26) or later
  • Kotlin 2.4 or later
  • JDK 17

Installation

Add Maven Central to your repositories, then add the SDK to your app module's build.gradle.kts:

dependencies {
    implementation("com.workos:workos-android:x.x.x")
}

Quickstart

Create a WorkOS account, copy your application's client ID, and register a redirect URI in the Dashboard. Use the same URI in your app's callback intent filter and when starting sign-in.

import com.workos.android.helpers.PublicClient

val workos = PublicClient.create(clientId = "client_...")
val authorization = workos.getAuthorizationUrlWithPkce(
    redirectUri = "com.example.myapp://callback",
)

Securely persist authorization.codeVerifier and authorization.state before opening authorization.url in a Custom Tab, not a WebView. Both values must survive Android process death while the browser is open.

When the callback arrives, handle cancellation and errors, and reject a missing or mismatched state. After validating it against the saved state, exchange the authorization code using the saved verifier from a coroutine:

val authentication = workos.authenticateWithCode(
    code = authorizationCode,
    codeVerifier = savedCodeVerifier,
)

Clear the pending verifier and state after the exchange, including on failure. Keep access tokens in memory and refresh tokens in Keystore-backed storage; never log either token.

Next steps

Contributing

See CONTRIBUTING.md for development and generated-code guidance.

License

MIT

About

Official Android (Kotlin) SDK for interacting with the WorkOS API

Topics

Resources

Contributing

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages