If you are using this library on the JVM platform, especially with Kotlin, we recommend that you migrate to kmisskey. This library is being migrated to maintenance only.
Misskey4J is client library to call api to Misskey written in java. This will be able to compile with google/j2objc to Objective-C library. (iOS, Mac OS)
You can install via JitPack with gradle. Add the JitPack repository to your build file.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
And add the dependency as bellow.
dependencies {
implementation 'com.github.uakihir0:misskey4j:0.1'
}
First, you must register your application to Misskey instance server (like as misskey.io).
Misskey misskey = MisskeyFactory.getInstance(HOST);
Response<CreateAppResponse> response =
misskey.app().createApp(
CreateAppRequest.builder()
.name("Misskey4J")
.description("Misskey4J Test")
.callbackUrl("http://localhost:8080/")
.permission(Scope.ALL)
.build());
System.out.println("Secret:" + response.get().getSecret());
next, generate user authentication url from client secret.
Misskey misskey = MisskeyFactory.getInstance(HOST);
Response<GenerateAuthSessionResponse> response =
misskey.auth().sessionGenerate(
GenerateAuthSessionRequest.builder()
.appSecret(CLIENT_SECRET)
.build());
System.out.println("URL: " + response.get().getUrl());
and user access to url, and get verify token which include redirected url as param. finally get user access token as followings.
Misskey misskey = MisskeyFactory.getInstance(HOST);
Response<UserKeyAuthSessionResponse> response =
misskey.auth().sessionUserKey(
UserKeyAuthSessionRequest.builder()
.token("VERIFY TOKEN")
.appSecret(CLIENT_SECRET)
.build());
System.out.println("USER TOKEN: " + response.get().getAccessToken());
System.out.println("NAME: " + response.get().getUser().getName());
First, issue an access token from the Misskey Web UI's Configuration > API.
Misskey misskey = MisskeyFactory.getInstanceWithOwnedAccessToken(HOST, OWNED_ACCESS_TOKEN);
Response<IResponse> response = misskey.accounts().i(IRequest.builder().build());
System.out.println("NAME: " + response.get().getName());
after that, you can access to any endpoints. If you want to need more information see misskey api document or test codes in this repository.
This software is released under the MIT License, see LICENSE.txt.