JELoginHandler
Login, logout, account managements.
Last updated
Login, logout, account managements.
Last updated
For more detailed initialization, which includes specifying how accounts are stored, setting up HttpClient, and more, please refer to JELoginHandlerBuilder.
This method tries Authenticating with the Most Recent Account first and if it fails, tries Authenticating with New Account.
Add a new account to sign in. Show the user the Microsoft OAuth page to enter their Microsoft account.
This method uses Microsoft WebView2 for displaying Microsoft OAuth login page. You must know that:
Microsoft WebView2 is only available on Windows. For another platform, see Authentication with MSAL.
To run WebView2, The users (including developer and end user) must have the WebView2 Runtime installed. See this document to distribute your launcher with WebView2. (For example, you can automate runtime installation with direct download link: https://go.microsoft.com/fwlink/p/?LinkId=2124703)
If you don't want to use WebView2, see Authentication with MSAL.
Using the saved account information of the most account, log in.
If the user is already logged in, this method returns the logged in information immediately.
If the user's login information has expired, try to refresh it. No user interaction nor webview is required during this process.
If there is no saved login information or if refresh failed, an MicrosoftOAuthException
will be thrown. In this case you should authenticate again using new account methods like Authenticating with New Account.
After a successful login, the account is saved. Above code list all saved account lists.
Select account by index number:
All account has unique string to identifiy them. Select account by identifier:
Select account by JE username:
Load account list and authenticate with second account (index number 1).
Signout
method does not clear WebView2 browser cache. For clearing it, call SignoutWithBrowser
instead.
Signout
method does not clear WebView2 browser cache. For clearing it, call SignoutWithBrowser
instead.
Load account list and sign out from second account (index number 1).
The login process has four main steps. There are many methods to customize authentication flow in each main step. You must select only one method for each step.
Initialize Authenticator
instance with the specific account to login. Another ways to initialize this:
Initialize Authenticator
with new empty account.
Initialize Authenticator
with the most recent account.
You can pass CancellationToken instead of default
.
Set Microsoft OAuth mode. Instead of oauth => oauth.Interactive()
, there are many options you can replace with. See OAuth.
AddMicrosoftOAuthForJE
and AddForceMicrosoftOAuthForJE
methods add default MicrosoftOAuthClientInfo
which Mojang Minecraft launcher uses so that you don't need to pass it everytime you use.
Note that the default Microsoft OAuth is only available on Windows platform. For another platform (Linux, macOS) you need XboxAuthNet.Game.Msal.
Set Xbox authentication mode. Instead of xbox => xbox.Basic()
, there are many options you can replace with. See XboxAuth.
AddXboxAuthForJE
and AddForceXboxAuthForJE
methods add default xbox authentication relying party which is used for Minecraft: JE authentication so that you don't need to pass it everytime you use.
Set Minecraft: JE authentication mode. See JEAuthenticator.