Skip to content

uakihir0/kmisskey

Repository files navigation

日本語

kmisskey

Maven metadata URL

badge badge badge badge

This library is a Misskey client library that supports Kotlin Multiplatform. It depends on khttpclient and internally uses Ktor Client. Therefore, this library is available on Kotlin Multiplatform and platforms supported by Ktor Client. The behavior on each platform depends on khttpclient.

Usage

Below is how to use it in Kotlin with Gradle on supported platforms. If you want to use it on Apple platforms, please refer to kmisskey-cocoapods. Also, for usage in JavaScript, please refer to kmsskey.js. Please refer to the test code for how to use each API.

repositories {
    mavenCentral()
+   maven { url = uri("https://repo.repsy.io/mvn/uakihir0/public") }
}

dependencies {
+   implementation("work.socialhub.kmisskey:core:0.0.1-SNAPSHOT")
+   implementation("work.socialhub.kmisskey:stream:0.0.1-SNAPSHOT")
}

Authentication

Using MiAuth, request the URL for users to authenticate as follows.

val misskey = MisskeyFactory.instance("HOST")

val response = misskey.auth().getMiAuthUri(
    GetMiAuthUriRequest().also { r ->
        r.name = "APP_NAME"
        r.callbackUrl = "APP_CALLBACK_URL"
        r.permission = Scope.ALL.map { it.target }
    }
)

println("URL:" + response.data)

After the user authenticates and is redirected, obtain the token from the redirected URL and get the access token as follows.

val response =
    misskey.auth().sessionUserKey(
        UserKeyAuthSessionRequest().also {
            it.token = "VERIFY_TOKEN"
            it.appSecret = "CLIENT_SECRET"
        }
    )

println("USER TOKEN: " + response.data.accessToken)

Create Note

val misskey = MisskeyFactory.instance(
    "HOST", 
    "CLIENT_SECRET", 
    "ACCESS_TOKEN",
)

misskey.notes().create(
    NotesCreateRequest().also {
        it.text = "Hello World!"
        it.visibility = "home"
    })

License

MIT License

Author

Akihiro Urushihara

Releases

No releases published

Packages

No packages published

Languages