Simple Android librirary to obtain, exchange, and do logout via Keycloak token. Based on this solution. Rewrited on Java, simplified to use as some kind a "Helper".
Library dependencies:
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency:
dependencies {
implementation 'com.github.7Koston:KeycloakToken:1.0.6'
}
new Config(
"https", // protocol
"://DOMAIN/auth/realms/REALM_TYPE/protocol/openid-connect", // base url
"://DOMAIN/auth/realms/REALM_TYPE/protocol/openid-connect/auth", // authentication url
"CLIENT_ID", // from Keycloak console
"REDIRECT_URL"); // from Keycloak console, with your protocol
Then initialize KeycloakTokenAPI
with your OkHttp client and use as your wish.
You can also take a look at example in repository. There an simple MVP application with RxJava3 in a simple approach.
This project is licensed under the Apache 2.0 - see the LICENSE file for details