https://github.com/mooziii/piston-meta-kt
Kotlin library to interact with mojangs launchermeta and "piston-meta" api
https://github.com/mooziii/piston-meta-kt
http kotlin ktor launchermeta microsoft-auth minecraft minecraft-login mojang
Last synced: 6 months ago
JSON representation
Kotlin library to interact with mojangs launchermeta and "piston-meta" api
- Host: GitHub
- URL: https://github.com/mooziii/piston-meta-kt
- Owner: mooziii
- License: gpl-3.0
- Created: 2022-08-08T20:48:56.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-05T18:27:07.000Z (over 3 years ago)
- Last Synced: 2023-07-28T14:40:22.607Z (almost 3 years ago)
- Topics: http, kotlin, ktor, launchermeta, microsoft-auth, minecraft, minecraft-login, mojang
- Language: Kotlin
- Homepage:
- Size: 270 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# piston-meta-kt
Kotlin library to interact with mojangs [launchermeta](https://launchermeta.mojang.com/mc/game/version_manifest_v2.json) and "[piston-meta](https://piston-meta.mojang.com/v1/packages/68cded4616fba9fbefb3f895033c261126c5f89c/1.19.2.json)" api as well as authenticating with Minecraft via Microsoft-Auth
### Add the dependency
**Gradle (Kotlin)**
```kotlin
implementation("me.obsilabor:piston-meta-kt:1.0.8")
```
**Gradle (Groovy)**
```groovy
implementation 'me.obsilabor:piston-meta-kt:1.0.8'
```
**Maven**
```xml
me.obsilabor
piston-meta-kt
1.0.8
```
## Usage
```kotlin
suspend fun main() {
val versions = PistonMetaClient.getLauncherMeta().versions
for (version in versions) {
println(version > MinecraftVersions.OLD_ALPHA_A1_0_17_02) // Compare versions!
}
}
```
### Authenticate with minecraft accounts
```kotlin
val msauth = MicrosoftAuth("URL_PREFIX", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", ssl = true) {
println(it.id) // specific auth id
println(it.token.user) // xbox user id
println(it.token.value) // minecraft access token
println(it.minecraftUUID) // minecraft uuid
println(it.minecraftName) // minecraft name
}
println(msauth.generateURI("specific_auth_id"))
msauth.setup(PORT) // Blocks the thread until the ktor server stops for whatever reason
```
You have to register an **Azure App** and add the following as **Web Redirect URI**: `https:///msauth/done` (SSL is required if you aren't using localhost!)
Note: `URL_PREFIX` is your domain without the `https://` (If you're using localhost you have to specify the port here.)
For a deeper understanding of whats happening you may take a look at [this documentation](https://mojang-api-docs.netlify.app/authentication/index.html)