11package org .geysermc .mcprotocollib .auth .example ;
22
33import net .raphimc .minecraftauth .MinecraftAuth ;
4- import net .raphimc .minecraftauth .step .java .StepMCProfile ;
5- import net .raphimc .minecraftauth .step .java .StepMCToken ;
6- import net .raphimc .minecraftauth .step .java .session .StepFullJavaSession ;
7- import net .raphimc .minecraftauth .step .msa .StepCredentialsMsaCode ;
4+ import net .raphimc .minecraftauth .java .JavaAuthManager ;
5+ import net .raphimc .minecraftauth .java .model .MinecraftProfile ;
6+ import net .raphimc .minecraftauth .java .model .MinecraftToken ;
7+ import net .raphimc .minecraftauth .msa .model .MsaCredentials ;
8+ import net .raphimc .minecraftauth .msa .service .impl .CredentialsMsaAuthService ;
89import org .geysermc .mcprotocollib .auth .GameProfile ;
910import org .geysermc .mcprotocollib .auth .SessionService ;
1011import org .geysermc .mcprotocollib .network .ProxyInfo ;
@@ -27,24 +28,24 @@ private static void auth() {
2728 SessionService service = new SessionService ();
2829 service .setProxy (PROXY );
2930
30- StepFullJavaSession . FullJavaSession fullJavaSession ;
31+ JavaAuthManager authManager ;
3132 try {
32- fullJavaSession = MinecraftAuth .JAVA_CREDENTIALS_LOGIN . getFromInput (
33- MinecraftAuth . createHttpClient (),
34- new StepCredentialsMsaCode . MsaCredentials ( EMAIL , PASSWORD ));
33+ authManager = JavaAuthManager . create ( MinecraftAuth .createHttpClient ()). login ( CredentialsMsaAuthService :: new , new MsaCredentials ( EMAIL , PASSWORD ));
34+ authManager . getMinecraftToken (). refresh (); // Preload the Minecraft token
35+ authManager . getMinecraftProfile (). refresh (); // Preload the Minecraft profile
3536 } catch (Exception e ) {
3637 throw new RuntimeException (e );
3738 }
3839
39- StepMCProfile . MCProfile mcProfile = fullJavaSession . getMcProfile ();
40- StepMCToken . MCToken mcToken = mcProfile . getMcToken ();
40+ MinecraftProfile mcProfile = authManager . getMinecraftProfile (). getCached ();
41+ MinecraftToken mcToken = authManager . getMinecraftToken (). getCached ();
4142 GameProfile profile = new GameProfile (mcProfile .getId (), mcProfile .getName ());
4243 try {
4344 service .fillProfileProperties (profile );
4445
4546 log .info ("Selected Profile: {}" , profile );
4647 log .info ("Selected Profile Textures: {}" , profile .getTextures (REQUIRE_SECURE_TEXTURES ));
47- log .info ("Access Token: {}" , mcToken .getAccessToken ());
48+ log .info ("Access Token: {}" , mcToken .getToken ());
4849 log .info ("Expire Time: {}" , mcToken .getExpireTimeMs ());
4950 } catch (Exception e ) {
5051 log .error ("Failed to get properties and textures of selected profile {}." , profile , e );
0 commit comments