use of com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication in project MinecraftForge by MinecraftForge.
the class Yggdrasil method login.
public static void login(Map<String, String> args) {
if (!args.containsKey("--username") || !args.containsKey("--password"))
return;
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(args.get("--username"));
auth.setPassword(args.remove("--password"));
try {
auth.logIn();
} catch (AuthenticationException e) {
LogManager.getLogger("FMLTWEAK").error("-- Login failed! " + e.getMessage());
Throwables.propagate(e);
// don't set other variables
return;
}
args.put("--username", auth.getSelectedProfile().getName());
args.put("--uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
args.put("--accessToken", auth.getAuthenticatedToken());
args.put("--userProperties", auth.getUserProperties().toString());
}
use of com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication in project Wurst-MC-1.12 by Wurst-Imperium.
the class LoginManager method login.
public static String login(String email, String password) {
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(email);
auth.setPassword(password);
try {
auth.logIn();
Minecraft.getMinecraft().session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
return "";
} catch (AuthenticationUnavailableException e) {
return "�4�lCannot contact authentication server!";
} catch (AuthenticationException e) {
e.printStackTrace();
if (e.getMessage().contains("Invalid username or password.") || e.getMessage().toLowerCase().contains("account migrated"))
return "�4�lWrong password!";
else
return "�4�lCannot contact authentication server!";
} catch (NullPointerException e) {
return "�4�lWrong password!";
}
}
Aggregations