use of net.technicpack.minecraftcore.mojang.auth.request.RefreshRequest in project LauncherV3 by TechnicPack.
the class MojangAuthenticator method requestRefresh.
public AuthResponse requestRefresh(MojangUser mojangUser) throws AuthenticationException {
RefreshRequest refreshRequest = new RefreshRequest(mojangUser.getAccessToken(), mojangUser.getClientToken());
String data = MojangUtils.getGson().toJson(refreshRequest);
AuthResponse response;
try {
String returned = postJson(AUTH_SERVER + "refresh", data);
response = MojangUtils.getGson().fromJson(returned, AuthResponse.class);
if (response == null) {
throw new SessionException("Session Error. Try logging in again.");
}
if (response.hasError()) {
throw new ResponseException(response.getError(), response.getErrorMessage());
}
} catch (IOException e) {
throw new AuthenticationException("An error was raised while attempting to communicate with " + AUTH_SERVER + ".", e);
}
return response;
}
Aggregations