JELoginHandler only works on Windows. To use it on another platform, you must use it with XboxAuthNet.Game.Msal.
There are two ways to use CmlLib.Core.Auth.Microsoft with XboxAuthNet.Game.Msal.
Register an OAuthProvider when initializing JELoginHandler.
Create an IAuthenticator and add a MSAL authenticator.
Register an OAuthProvider
Register the OAuthProvider when initializing the JELoginHandler so that all subsequent methods you call will handle the login with the MSAL.
var app =awaitMsalClientHelper.BuildApplicationWithCache("CLIENT-ID");var loginHandler =newJELoginHandlerBuilder() .WithOAuthProvider(newMsalCodeFlowProvider(app)) .Build();// loginvar session =awaitloginHandler.Authenticate();// add new accountvar session =awaitloginHandler.AuthenticateInteractively();// login with most recently logged in accountvar session =awaitloginHandler.AuthenticateSilently();// clearawaitloginHandler.Signout();// signoutawaitloginHandler.SignoutWithBrowser();
For more information about loginHandler, see JELoginHandler.
Using AddMsalOAuth
Authenticating with new account:
var app =awaitMsalClientHelper.BuildApplicationWithCache("CLIENT-ID");var loginHandler =newJELoginHandlerBuilder() .Build();// create authenticator with new accountvar authenticator =loginHandler.CreateAuthenticatorWithNewAccount();authenticator.AddMsalOAuth(app, msal =>msal.Interactive());authenticator.AddXboxAuthForJE(xbox =>xbox.Basic());authenticator.AddForceJEAuthenticator();var session =awaitauthenticator.ExecuteForLauncherAsync();
Authenticating with the most recent account:
var app =awaitMsalClientHelper.BuildApplicationWithCache("CLIENT-ID");var loginHandler =newJELoginHandlerBuilder() .Build();// create authenticator with the most recent accountvar authenticator =loginHandler.CreateAuthenticatorWithDefaultAccount();authenticator.AddMsalOAuth(app, msal =>msal.Silent());authenticator.AddXboxAuthForJE(xbox =>xbox.Basic());authenticator.AddJEAuthenticator();var session =awaitauthenticator.ExecuteForLauncherAsync();