• Stars
    star
    156
  • Rank 234,097 (Top 5 %)
  • Language
    Java
  • License
    GNU General Publi...
  • Created about 9 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java Yggdrasil library.

OpenAuth Logo

Minecraft authentication library which supports both Mojang and Microsoft accounts, or even custom servers

Credits

This project would have not existed without the work from:

Importing library

Gradle

repositories {
    maven {
        url 'https://litarvan.github.io/maven'
    }
}

dependencies {
    implementation 'fr.litarvan:openauth:1.1.3'
}

Maven

<repositories>
    <repository>
        <id>litarvan</id>
        <url>https://litarvan.github.io/maven</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>fr.litarvan</groupId>
        <artifactId>openauth</artifactId>
        <version>1.1.3</version>
    </dependency>
</dependencies>

Other

Use the JAR file from releases, or from the GitHub Actions.

How to use it (Microsoft)

MicrosoftAuthenticator authenticator = new MicrosoftAuthenticator();
MicrosoftAuthResult result = authenticator.loginWithCredentials("email", "password");
      // Or using a webview: authenticator.loginWithWebView();
  // Or using refresh token: authenticator.loginWithRefreshToken("refresh token");
   // Or using your own way: authenticator.loginWithTokens("access token", "refresh token");
        
System.out.printf("Logged in with '%s'%n", result.getProfile().getName());

You can save the refresh token (result.getRefreshToken()) to log back the user silently later.

How to use it (Mojang)

Use it to connect to any yggdrasil server (The Mojang official auth server, or any openauth server, and maybe other servers !)

Init it

First init the authenticator with settings from your server :

AuthPoints points = new AuthPoints("authpage", "refreshpage", "validatepage", "signoutpage", "invalidatepage");
Authenticator authenticator = new Authenticator("urlofyourserver", points);

So the auth points are the url (relative to the main url) of all your page, you can give only page that you wan't to use ! urlofyourserver is of course the URL of yout Yggdrasil server.

You can use pre-made auth points : AuthPoints.MOJANG_AUTH_POINTS or AuthPoints.OPENAUTH_AUTH_POINTS You can alose user the official mojang server : Authenticator.MOJANG_AUTH_URL

Send a request !

Authenticate

Receive an access token by authenticating an user

AuthResponse response = authenticator.authenticate(authagent, "username", "password", "clientToken");

So, replace auth agent with your auth agent (Minecraft, Scrolls, or other) pre-made agent are AuthAgent.MINECRAFT and AuthAgent.SCROLLS. Auth Agent are used to get the profile of the account of your server, every accounts have some profiles, one profile is one game, so to create yout auth agent object, use :

AuthAgent myAgent = new AuthAgent("name", version);

You can manage the profiles in the server ^^ The Auth agent is optional, if you don't send it, response.getSelectedProfile() and response.getAvailableProfiles() will be null.

Replace username with the username of the user account, and password with the password of the user account you wanna auth !

The client token is like a key to protect the access token if you wan't, it is optional !

Every profiles has a username and an ID, user (profile).getName() and (profile).getId() to get them !

Refresh

Receive a new access token by re-authenticating an user with the saved access token of the previous authentication

RefreshResponse response = authenticator.refresh("accessToken", "clientToken");

Replace accessToken by the saved access token from the previous authentication of the user you wanna re-auth, and clientToken by the client token given when authenticating (optinal if you didn't give it)

The reponse is near the same as the auth response (selectedProfile, accessToken, etc...)

Validate

This is to check an access token, WARNING : This method should not be used by the client. Juste do

authenticator.validate("accessToken");

Signout

Invalidate an access token using the username and the password of the user that had the access token

authenticator.signout("username", "password");

Invalidate

Invalidate an access token using the access token and its client token

authenticator.invalidate("accessToken", "clientToken");

More Repositories

1

lightdm-webkit-theme-litarvan

Litarvan's LightDM HTML Theme
Vue
706
star
2

pronote-api

(Tout langage) API compatible Pronote 2020/2021
193
star
3

OpenLauncherLib

A simple modern java launching library with minecraft support
Java
67
star
4

infinity-pegasus

Make Pegasus great again!
JavaScript
52
star
5

S-Update

A Java easy and complete update library
Java
23
star
6

Swinger

A Java library to use with Swing.
Java
18
star
7

S-Update-Server

The S-Update update server
JavaScript
18
star
8

OpenAuth-Server

The OpenAuth Yggdrasil server
PHP
12
star
9

pronote-api-client-java

Client Pronote-API en Java
Java
10
star
10

nix-litarvan

My Nix user configuration
Nix
10
star
11

tiger-idea

Tiger language plugin for IntelliJ/CLion/...
Java
8
star
12

stats-bot

Discord statistics bot
JavaScript
7
star
13

epita-aled

ALED
Vue
7
star
14

epita-aled-content

Articles du site Epita ALED
7
star
15

nix

My nix system configuration
Nix
5
star
16

Sender

An easy local file sender, I created it just for learning socket with Java, but i did wanna share it :)
Java
4
star
17

server-queue

Minecraft server connection queue server and API
Java
4
star
18

Feelcraft

A new Minecraft experience - This mod will get your Minecraft window into a virtual desktop, with other little windows created by community plugins.
Java
4
star
19

leviathan

self-hosted infrastructure behind (*.)litarvan.com
Nix
4
star
20

slark-server

Server for the Slark update framework
PHP
4
star
21

Shark-Engine

An easy Java game engine. WIP
Java
3
star
22

DotPacket

.NET (Core/Framework) easy-to-use network packet library
C#
3
star
23

hello-world

Simple C Hello World built with a Makefile
Makefile
3
star
24

MineJS

Une interface graphique Web pour serveur minecraft
JavaScript
3
star
25

Paladin

The lightest and simplest PHP framework ever made.
PHP
3
star
26

Shenron

My Discord bot
Java
3
star
27

Rebyte

Byte per byte file reading system, very easy to use, and totally extensible.
Java
3
star
28

MineJS-GUI

A graphical version of MineJS
JavaScript
3
star
29

JavaMurmur

Simple Java Murmur 3 library
Java
2
star
30

EpiTrack

EPITA's community TrackMania 2 Stadium dedicated server
Python
2
star
31

litarvan-commons

Commons Java library
Java
2
star
32

litarvan.com.nix

litarvan.com server NixOS configuration
Nix
2
star
33

Litarvan.github.io

My github website !
HTML
2
star
34

Reprops

Stock everything you want in a JavaProperties like system, in an unreadable file.
Java
2
star
35

Packetz

Java packet network library (Minecraft compatible)
Java
1
star
36

fishdoc

Modern Java documentation
Java
1
star
37

kube-argo-test

1
star
38

Sandstone

Bringing forge-like ASM to Bukkit.
Java
1
star
39

docker-jlink-alpine

Docker Alpine images ready for a JLink JVM
Dockerfile
1
star
40

Papersheet

CSS Helpers - The CSS stylesheet for lazy people
CSS
1
star
41

SandstoneAPI

The Sandstone API. Bringing forge-like ASM to Bukkit.
Java
1
star