{"id":42502188,"url":"https://github.com/kalinjul/kotlin-multiplatform-oidc","last_synced_at":"2026-01-28T13:21:35.104Z","repository":{"id":207183281,"uuid":"717845466","full_name":"kalinjul/kotlin-multiplatform-oidc","owner":"kalinjul","description":"Kotlin Multiplatform OpenIDConnect implementation for Android/iOS","archived":false,"fork":false,"pushed_at":"2026-01-27T14:30:45.000Z","size":950,"stargazers_count":148,"open_issues_count":15,"forks_count":38,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-01-28T01:40:49.903Z","etag":null,"topics":["android","authorization","ios","kotlin","mobile","multiplatform","oauth2","openid-connect"],"latest_commit_sha":null,"homepage":"https://kalinjul.github.io/kotlin-multiplatform-oidc/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kalinjul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-12T19:24:01.000Z","updated_at":"2026-01-21T15:53:55.000Z","dependencies_parsed_at":"2023-12-20T17:29:40.334Z","dependency_job_id":"79d00bc6-f854-4666-aa08-11a8c49df487","html_url":"https://github.com/kalinjul/kotlin-multiplatform-oidc","commit_stats":null,"previous_names":["kalinjul/kotlin-multiplatform-oidc"],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/kalinjul/kotlin-multiplatform-oidc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalinjul%2Fkotlin-multiplatform-oidc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalinjul%2Fkotlin-multiplatform-oidc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalinjul%2Fkotlin-multiplatform-oidc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalinjul%2Fkotlin-multiplatform-oidc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kalinjul","download_url":"https://codeload.github.com/kalinjul/kotlin-multiplatform-oidc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalinjul%2Fkotlin-multiplatform-oidc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","authorization","ios","kotlin","mobile","multiplatform","oauth2","openid-connect"],"created_at":"2026-01-28T13:21:34.465Z","updated_at":"2026-01-28T13:21:35.097Z","avatar_url":"https://github.com/kalinjul.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin Multiplatform OIDC\n[![Build](https://img.shields.io/github/actions/workflow/status/kalinjul/kotlin-multiplatform-oidc/main.yml)]((https://github.com/kalinjul/kotlin-multiplatform-oidc/actions/workflows/main.yml))\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.kalinjul.kotlin.multiplatform/oidc-appsupport)](https://central.sonatype.com/repository/maven-snapshots/io/github/kalinjul/kotlin/multiplatform/oidc-appsupport/)\n![Kotlin Version](https://kotlin-version.aws.icerock.dev/kotlin-version?group=io.github.kalinjul.kotlin.multiplatform\u0026name=oidc-appsupport)\n\nKotlin Multiplatform Library for OpenId Connect / OAuth 2.0.\n\nThe library is designed for kotlin multiplatform, Android-only _and_ iOS only Apps.\nFor iOS only, use the [OpenIdConnectClient Swift Package](https://github.com/kalinjul/OpenIdConnectClient).\n\nThis is a lightweight implementation that does not provide any client-side validation of signatures.\n\nSupported platforms:\n\n|         | State        | Implementation                               |\n|---------|--------------|----------------------------------------------|\n| Android | Stable       | Chrome Custom Tabs                           |\n| iOS     | Stable       | ASWebAuthenticationSession                   |\n| Desktop | Experimental | Embedded Webserver + Browser                 |\n| WasmJS  | Experimental | Popup Window communicating via postMessage() |\n\nFeatures:\n- Only supports [Authorization Code Grant Flow](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1).\n- Support for [discovery](https://openid.net/specs/openid-connect-discovery-1_0.html) via .well-known/openid-configuration.\n- Support for [PKCE](https://datatracker.ietf.org/doc/html/rfc7636)\n- Simple JWT parsing (```Jwt.parse()```)\n- OkHttp + Ktor integration\n- Uses Custom Uri Scheme (my-app://), no support for https redirect uris.\n\nYou can find the full Api documentation [here](https://kalinjul.github.io/kotlin-multiplatform-oidc/).\n\nLibrary dependency versions:\n\n| kmp-oidc version | kotlin version | ktor version |\n|------------------|----------------|--------------|\n| \u003c=0.11.1         | 1.9.23         | 2.3.7        |\n| 0.11.2           | 2.0.20         | 2.3.7        |\n| 0.12.+           | 2.0.20         | 3.0.+        |\n| 0.13.+           | 2.1.20         | 3.1.+        |\n| 0.14.0 - 0.15.+  | 2.1.21         | 3.2.+        |\n| 0.16.0           | 2.2.20         | 3.3.+        |\n\nNote that while the library may work with other kotlin/ktor versions, proceed at your own risk.\n\n# Dependency\nAdd the dependency to your commonMain sourceSet (KMP) / Android dependencies (android only):\n```kotlin\nimplementation(\"io.github.kalinjul.kotlin.multiplatform:oidc-appsupport:\u003cversion\u003e\")\nimplementation(\"io.github.kalinjul.kotlin.multiplatform:oidc-ktor:\u003cversion\u003e\") // optional ktor support\nimplementation(\"io.github.kalinjul.kotlin.multiplatform:oidc-okhttp4:\u003cversion\u003e\") // optional okhttp support (android only)\n```\n\nOr, for your libs.versions.toml:\n```toml\n[versions]\noidc = \"\u003cversion\u003e\"\n[libraries]\noidc-appsupport = { module = \"io.github.kalinjul.kotlin.multiplatform:oidc-appsupport\", version.ref = \"oidc\" }\noidc-okhttp4 = { module = \"io.github.kalinjul.kotlin.multiplatform:oidc-okhttp4\", version.ref = \"oidc\" }\noidc-ktor = { module = \"io.github.kalinjul.kotlin.multiplatform:oidc-ktor\", version.ref = \"oidc\" }\n```\n\n## Using a snapshot version\nIf you want try a snapshot version, just add ```maven(\"https://central.sonatype.com/repository/maven-snapshots/\")``` to your repositories.\nThere is currently no way to view available snapshots on sonatype central.\n\n## Compiler options\nIf you want to run tests, currently you need to pass additional linker flags (adjust the path to your Xcode installation): \n```kotlin\niosSimulatorArm64().compilerOptions {\n    freeCompilerArgs.set(listOf(\"-linker-options\", \"-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator\"))\n}\n```\n\n# Usage\n\n## Setup\nYou will need some basic project setup to handle redirect urls and create an instance of the AuthFlowFactory:\n\n[Setup Android](docs/setup-android.md)\n\n[Setup iOS](docs/setup-ios.md)\n\n[Setup Wasm](docs/setup-wasm.md)\n\n## OpenID Configuration\nCreate an [OpenIdConnectClient](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc/-open-id-connect-client/index.html):\n```kotlin\nval client = OpenIdConnectClient(discoveryUri = \"\u003cdiscovery url\u003e\") {\n    endpoints {\n        tokenEndpoint = \"\u003ctokenEndpoint\u003e\"\n        authorizationEndpoint = \"\u003cauthorizationEndpoint\u003e\"\n        userInfoEndpoint = null\n        endSessionEndpoint = \"\u003cendSessionEndpoint\u003e\"\n    }\n\n    clientId = \"\u003cclientId\u003e\"\n    clientSecret = \"\u003cclientSecret\u003e\"\n    scope = \"openid profile\"\n    codeChallengeMethod = CodeChallengeMethod.S256\n    redirectUri = \"\u003credirectUri\u003e\"\n    postLogoutRedirectUri = \"\u003cpostLogoutRedirectUri\u003e\"\n}\n```\nIf you provide a Discovery URI, you may skip the endpoint configuration and call [discover()](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc/-open-id-connect-client/discover.html) on the client to retrieve the endpoint configuration.\n\n## Authenticate\nThe Code Auth Flow method is implemented by [CodeAuthFlow](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc.flows/-code-auth-flow/index.html). You'll need platform specific variants (see [Setup](#Setup)).\nPreferably, those instances should be provided using Dependency Injection.\nFor more information, have a look at the [KMP sample app](./sample-app).\n\nRequest tokens using code auth flow (this will open the browser for login):\n```kotlin \nval flow = authFlowFactory.createAuthFlow(client)\nval tokens = flow.getAccessToken()\n```\n\nPerform refresh or endSession:\n```kotlin\ntokens.refresh_token?.let { client.refreshToken(refreshToken = it) }\ntokens.id_token?.let { client.endSession(idToken = it) }\n```\n\n# Token Store (experimental)\nSince persisting tokens is a common task in OpenID Connect Authentication, we provide a \n[TokenStore](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc.tokenstore/-token-store/index.html) that uses a [Multiplatform Settings Library](https://github.com/russhwolf/multiplatform-settings)\nto persist tokens in Keystore (iOS) / Encrypted Preferences (Android).\nIf you use the TokenStore, you may also make use of [TokenRefreshHandler](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc.tokenstore/-token-refresh-handler/index.html) for synchronized token\nrefreshes.\n```kotlin\ntokenstore.saveTokens(tokens)\nval accessToken = tokenstore.getAccessToken()\n\nval refreshHandler = TokenRefreshHandler(tokenStore = tokenstore)\nrefreshHandler.refreshAndSaveToken(client, oldAccessToken = token) // thread-safe refresh and save new tokens to store\n```\nAndroid implementation is [AndroidEncryptedPreferencesSettingsStore](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc.tokenstore/-android-encrypted-preferences-settings-store/index.html), for iOS use [IosKeychainTokenStore](https://kalinjul.github.io/kotlin-multiplatform-oidc/kotlin-multiplatform-oidc/org.publicvalue.multiplatform.oidc.tokenstore/-ios-keychain-token-store/index.html).\n\n# Ktor support (experimental)\nYou can use \"oidc-ktor\" dependency, which provides easy integration for ktor projects:\n\n```kotlin\nHttpClient(engine) {\n    install(Auth) {\n        oidcBearer(\n            tokenStore = tokenStore,\n            refreshHandler = refreshHandler,\n            client = client,\n        )\n    }\n}\n```\n\nBecause of the [way ktor works](https://youtrack.jetbrains.com/issue/KTOR-4759/Auth-BearerAuthProvider-caches-result-of-loadToken-until-process-death), you need to tell the client if the token is invalidated outside of ktor's refresh logic, e.g. on logout:\n```kotlin\nktorHttpClient.clearTokens()\n```\n\n## Custom headers/url parameters\nFor most calls (```getAccessToken()```, ```refreshToken()```, ```endSession()```), you may provide\nadditional configuration for the http call, like headers or parameters using the configure closure parameter:\n\n```kotlin\nclient.endSession(idToken = idToken) {\n    headers.append(\"X-CUSTOM-HEADER\", \"value\")\n    url.parameters.append(\"custom_parameter\", \"value\")\n}\n```\n\n```kotlin\nval tokens = flow.getAccessToken(configureAuthUrl = {\n    // customize url that is passed to browser for authorization requests\n    parameters.append(\"prompt\", \"login\")\n}, configureTokenExchange = {\n    // customize token exchange http request\n    header(\"additionalHeaderField\", \"value\")\n})\n```\n\n## End session using GET request and post_logout_redirect_uri\nIf you have configured a ```postLogoutRedirectUri``` and want to perform a Logout using a Web Flow,\nyou can use the endSession flow:\n```kotlin\nval flow = authFlowFactory.createEndSessionFlow(client)\ntokens.id_token?.let { flow.endSession(it) }\n```\nThat way, browser cookies should be cleared so the next time a client wants to login, it get's prompted for username and password again.\n\n# JWT Parsing\nWe provide simple JWT parsing (without any validation):\n```kotlin\nval jwt = tokens.id_token?.let { Jwt.parse(it) }\nprintln(jwt?.payload?.aud) // print audience\nprintln(jwt?.payload?.iss) // print issuer\nprintln(jwt?.payload?.additionalClaims?.get(\"email\")) // get claim\n```\n\n# OkHttp support (Android only) (experimental)\n```kotlin\nval authenticator = OpenIdConnectAuthenticator {\n    getAccessToken { tokenStore.getAccessToken() }\n    refreshTokens { oldAccessToken -\u003e refreshHandler.refreshAndSaveToken(client, oldAccessToken) }\n    onRefreshFailed {\n        // provided by app: user has to authenticate again\n    }\n    buildRequest {\n        header(\"AdditionalHeader\", \"value\") // add custom header to all requests\n    }\n}\n\nval okHttpClient = OkHttpClient.Builder()\n    .authenticator(authenticator)\n    .build()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalinjul%2Fkotlin-multiplatform-oidc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalinjul%2Fkotlin-multiplatform-oidc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalinjul%2Fkotlin-multiplatform-oidc/lists"}