You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authentication gameAuth = new Authentication(AccountType.MICROSOFT);
gameAuth.connectMicrosoft(contentPane); // contentPane == your Parent pane
if (gameAuth.isLogged()) {
// your action when the auth successful.
}
How to use (Mojang / Offline)
Authentication gameAuth = new Authentication("username", "password", AccountType.MOJANG); // MOJANG / OFFLINE
if (gameAuth.isLogged()) {
// your action when the auth successful.
}
Example class
public class Example extends Application {
public static void main(String[] args) {
launch(args);
}
private static Parent createMicrosoftPanel() {
Pane contentPane = new Pane();
/** Login Method **/
tryLogin(contentPane);
return contentPane;
}
private static void tryLogin(Pane contentPane) {
/** Set the Authentication to Microsoft services **/
GameAuth gameAuth = new GameAuth(AccountType.MICROSOFT);
gameAuth.connectMicrosoft(contentPane);
/** Set the Authentication to Mojang services **/
GameAuth gameAuth = new GameAuth("mail_adress", "secret_password", AccountType.MOJANG);
/** Set the Authentication to Offline (no authentication required) **/
GameAuth gameAuth = new GameAuth("super_username", "not_required", AccountType.OFFLINE);
if (gameAuth.isLogged()) {
Logger.log("Your username is " + gameAuth.getSession().getUsername());
Logger.log("Your token is " + gameAuth.getSession().getToken());
Logger.log("Your userID is " + gameAuth.getSession().getUuid());
}
}
@Override
public void start(Stage primaryStage) throws Exception {
Scene scene = new Scene(createMicrosoftPanel());
Stage stage = new Stage();
stage.setResizable(false);
stage.setTitle("Microsoft Authentication");
stage.setWidth(500);
stage.setHeight(600);
stage.setScene(scene);
stage.show();
}
}