An authentication library for authorizing your Minecraft accounts to your Minecraft clients.
- Create an Azure account, make an application, set redirect url to "http://localhost:PORT/callback" using Single-page.
- Obviously in the example above, please change the PORT value to the value you want to use.
- Copy down your application ID and replace
CLIENT_ID
in the example with your client ID.
final MSAAuthenticator msa = new MSAAuthenticator("CLIENT_ID", 5678);
final MinecraftProfile profile = msa.login("[email protected]", "youshallnotpass11");
final String url = msa.browser((accessToken) -> {
// You can do what you want with the access token, but we're going to login with it for example
final MinecraftProfile profile = msa.login(accessToken);
if (profile != null)
{
// Handle here
}
});
// For example, we'll browse to this URL
Desktop.getDesktop().browse(new URI(url));
// Or say you have a refresh token because your access token expired.
final String accessToken = msa.refresh(refreshToken);
final MinecraftProfile profile = msa.login(accessToken);