CmlLib
English (v4)
English (v4)
  • 🧊CmlLib Projects
  • 🚀CmlLib.Core
    • Home
    • Getting Started
      • Minecraft Launcher
      • Minecraft Path
      • Versions
      • Launch Options
      • Event Handling
    • Login and Sessions
      • Microsoft Xbox Account
      • Offline Account
    • More APIs
      • MinecraftLauncherParameters
      • Rules
      • FileExtractor
      • GameInstaller
      • Java
    • Mod Loader Installers
      • Forge Installer
      • Fabric Installer
      • Quilt Installer
      • LiteLoader Installer
    • Utilities
      • Minecraft Changelogs
    • Resources
      • FAQ
      • Known Issues
      • Sample Launcher
      • License
  • 🔓Auth.Microsoft
    • Home
    • CmlLib.Core.Auth.Microsoft
      • JELoginHandler
      • JELoginHandlerBuilder
      • JEAuthenticator
      • Authentication with MSAL
    • XboxAuthNet.Game
      • OAuth
      • XboxAuth
      • XboxAuthException
      • AccountManager
      • Accounts
    • XboxAuthNet.Game.Msal
      • ClientID
      • MsalClientHelper
      • OAuth
    • CmlLib.Core.Bedrock.Auth
    • Resources
  • 🌐MojangAPI
    • Home
    • Mojang API
    • SecurityQuestion
  • ⚒️Installer.Forge
    • Home
    • Supported Versions
    • Getting Started
    • MForge
    • ForgeVersionLoader
Powered by GitBook
On this page
  • Example
  • Basic
  • Full
  • Sisu
  • Device Options
  • Handling errors
Edit on GitHub
  1. Auth.Microsoft
  2. XboxAuthNet.Game

XboxAuth

Xbox Authentication

Example

var authenticator = // create authenticator using login handlers
authenticator.AddXboxAuthForJE(xbox => xbox.Basic());
//authenticator.AddXboxAuth(xbox => xbox.Basic(XboxAuthConstants.XboxLiveRelyingParty)); // same code

Basic

authenticator.AddXboxAuthForJE(xbox => xbox.Basic());
//authenticator.AddXboxAuth(xbox => xbox.Basic("relyingParty"));

This is the most basic method. It only gets the minimum information (UserToken, XstsToken) needed to log in.

Accounts that are not age-verified, and accounts that are under the age of 18 may experience issues when logging in this way (error codes 8015dc0c, 8015dc0d, 8015dc0e). You can work around this by using the Full method or the Sisu method.

Full

authenticator.AddXboxAuthForJE(xbox => xbox.Full());
//authenticator.AddXboxAuth(xbox => xbox.Full("relyingParty"));

Gets the UserToken, DeviceToken, and XstsToken.

Sisu

authenticator.AddXboxAuthForJE(xbox => xbox.Sisu(XboxGameTitles.MinecraftJava));
//authenticator.AddXboxAuth(xbox => xbox.Sisu("relyingParty",  "<CLIENT-ID>"));

Use the SISU login method. Get all tokens: UserToken, DeviceToken, TitleToken, XstsToken. Most age-related issues can be resolved this way.

This only works if <CLIENT-ID> is related to an Xbox game (for example, the CLIENT-ID used by the Minecraft launcher).

You can't use a personally issued Azure ID, i.e. you can't use it with MSAL.

Device Options

authenticator.AddXboxAuth(xbox => xbox
    .WithDeviceType(XboxDeviceTypes.Win32)
    .WithDeviceVersion("0.0.0")
    .Full("relyingParty"));

When using a authentication method that gets a DeviceToken, you can apply the Device settings. Call .WithDeviceType() and .WithDeviceVersion() before calling the authentication method.

Handling errors

There are various error scenarios when authenticating with Xbox. If an error occurs during authentication, an XboxAuthException is thrown and you can get an ErrorCode and ErrorMessage.

All ErrorCodes can be found XboxAuthException.

PreviousOAuthNextXboxAuthException

Last updated 10 months ago

🔓