/kotlin-oauth2

JVM base OAuth2 client library written in Kotlin for RIDI account authorization

Primary LanguageKotlinMIT LicenseMIT

kotlin-oauth2

Build Status Release

JVM base OAuth2 client library written in Kotlin for RIDI account authorization

Getting started

This library is distributed by jitpack.

You should add jitpack maven repository to build.gradle file of your project.

repositories {
    ...
    maven { url 'https://jitpack.io' }
    ...
}

Then you can include this library by adding dependency script to build.gradle file of your project.

dependencies {
    ...
    implementation 'com.github.ridi:kotlin-oauth2:<version>'
    ...
}

Android ProGuard

If you want to use this library on your Android project using ProGuard, add the following line to your ProGuard rules file.

-keepclassmembers class com.ridi.oauth2.TokenResponse { *; }

API

Create Authorization object with your client id and client secret.

val authorization = Authorization("client-id", "client-secret")

You can get Single<TokenResponse> object by following examples.

Password grant

authorization.requestPasswordGrantAuthorization("username", "password")

Refresh access token

authorization.refreshAccessToken("refresh-token")