Skip to content

Authentication

spnkr.auth

Logic for obtaining API credentials.

AuthenticatedPlayer dataclass

Information about an authenticated player.

Attributes:

Name Type Description
player_id str

Xbox Live ID of the player.

gamertag str

The player's gamertag.

spartan_token SpartanToken

An expirable Spartan token required for all API endpoints.

clearance_token ClearanceToken

A clearance token required for some API endpoints.

xbl_authorization_header_value str

The value for the authorization header passed when making requests to the Xbox Live API.

is_valid: bool property

Whether the player's Spartan token is still valid.

AzureApp dataclass

An Azure Active Directory (Azure AD) application.

Azure AD is a cloud-based identity and access management service from Microsoft. It allows you to sign in and access Microsoft resources from an application.

Attributes:

Name Type Description
client_id str

The client ID of the application.

client_secret str

The client secret of the application.

redirect_uri str

The redirect URI of the application. Defaults to "https://localhost".

ClearanceToken dataclass

A Halo Infinite clearance token response.

A clearance token is required for some API endpoints.

Attributes:

Name Type Description
raw dict[str, Any]

The raw, deserialized JSON response.

token: str property

The flight configuration ID.

SpartanToken dataclass

Response resulting from a request for a Spartan token.

This provides the primary means of authenticating with the Halo Infinite API. The tokens are valid for 4 hours.

Attributes:

Name Type Description
raw dict[str, Any]

The raw, deserialized JSON response.

expires_at: dt.datetime property

The UTC datetime at which the Spartan token expires.

token: str property

The spartan token value.

authenticate_player(session, app) async

Initial authentication of the app with Windows Live and Xbox Live.

Request an OAuth token and return its refresh token. Save the refresh token for future use.

Parameters:

Name Type Description Default
session ClientSession

The session to use for requests.

required
app AzureApp

The Azure AD application to authenticate.

required

Returns:

Type Description
str

The OAuth refresh token.

refresh_player_tokens(session, app, oauth_refresh_token) async

Refresh all tokens and return authenticated player information.

Parameters:

Name Type Description Default
session ClientSession

The session to use for requests.

required
oauth_refresh_token str

The OAuth refresh token.

required
app AzureApp

The Azure AD application to authenticate.

required

Returns:

Type Description
AuthenticatedPlayer

The authenticated player information.