getMinecraftTokenWithXstsToken method

Future<String?> getMinecraftTokenWithXstsToken(
  1. String uhs,
  2. String xstsToken
)

Gets a Minecraft access token directly using XSTS token and UHS

This method allows obtaining a Minecraft access token using the Xbox XSTS token and User Hash (UHS) without going through the full Microsoft authentication flow.

@param uhs The User Hash (UHS) from Xbox authentication @param xstsToken The XSTS token from Xbox authentication @return A Future that resolves to the Minecraft access token, or null if the operation failed

Implementation

Future<String?> getMinecraftTokenWithXstsToken(
  String uhs,
  String xstsToken,
) async {
  try {
    final tokenResponse = await _minecraftAuthService.getMinecraftAccessToken(
      uhs,
      xstsToken,
    );
    return tokenResponse.accessToken;
  } catch (e) {
    debugPrint('Failed to get Minecraft token with XSTS: $e');
    return null;
  }
}