List of all methods exposed by the library.
Authenticate the user.
Clone of the initial authenticate
method.
Authenticate the user with its refresh_token
.
Pre-authentication request used to retrieve mandatory authentication parameters.
import { live } from '@xboxreplay/xboxlive-auth';
const preAuthResponse = await live.preAuth();
console.log(preAuthResponse);
- options {object=}
- clientId {string=} -
000000004C12AE6F
- scope {string=} -
service::user.auth.xboxlive.com::MBI_SSL
- responseType {token|code=} -
token
- redirectUri {string=} -
https://login.live.com/oauth20_desktop.srf
- clientId {string=} -
{
"cookie": "MSA=...; X=...; ...",
"matches": {
"PPFT": "abcde...",
"urlPost": "https://login.live.com/..."
}
}
Exchange returned "RpsTicket" from login.live.com authorization process.
import { xbl } from '@xboxreplay/xboxlive-auth';
const loginResponse = {
token_type: 'bearer',
expires_in: 86400,
access_token: 'EwAIA+pvBAAUK...', // RpsTicket
refresh_token: 'M.R3_BAY...',
scope: 'service::user.auth.xboxlive.com::MBI_SSL',
user_id: '123abc...'
};
const rpsTicket = loginResponse.access_token;
const userTokenResponse = await xbl.exchangeRpsTicketForUserToken(
rpsTicket,
'd' // Required if using a custom Azure applications
);
console.info(userTokenResponse);
- rpsTicket {string}
- preable {d|t=} -
t
- Used
for custom Azure applications - additionalHeaders {object=} -
{}
- Additional headers if required, can be used to override default ones
{
"IssueInstant": "2021-01-14T18:55:20.0082007Z",
"NotAfter": "2021-01-15T10:55:20.0082007Z",
"Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"DisplayClaims": {
"xui": [{ "uhs": "3218841136841218711" }]
}
}
Exchange returned token by the exchangeRpsTicketForUserToken
method.
import { xbl } from '@xboxreplay/xboxlive-auth';
const userTokenExchangeResponse = {
IssueInstant: '2021-01-14T18:55:20.0082007Z',
NotAfter: '2021-01-15T10:55:20.0082007Z',
Token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
DisplayClaims: {
xui: [{ uhs: '3218841136841218711' }]
}
};
const userToken = userTokenExchangeResponse.Token;
const XSTSTokenResponse = await xbl.exchangeTokenForXSTSToken(userToken);
console.info(XSTSTokenResponse);
- userToken {string}
- options {object=}
- XSTSRelyingParty {string=} -
http://xboxlive.com
- Targeted RelyingParty - optionalDisplayClaims {string[]=} -
[]
- Optional display claims to be returned based on the used RelyingParty - sandboxId {string=} -
RETAIL
- Targeted sandbox ID
- XSTSRelyingParty {string=} -
- additionalHeaders {object=} -
{}
- Additional headers if required, can be used to override default ones
{
"IssueInstant": "2021-01-14T18:55:20.0082007Z",
"NotAfter": "2021-01-15T10:55:20.0082007Z",
"Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"DisplayClaims": {
"xui": [{
"gtg": "Zeny IC",
"xid": "2584878536129841",
"uhs": "3218841136841218711",
"agg": "Adult",
"usr": "234",
"utr": "190",
"prv": "185 186 187 188 191 192 ..."
}]
}
}
Exchange returned token by the exchangeRpsTicketForUserToken
method. This method also allows you to specify your own device token and title token. Please note that based on your scenario, the userTokens
parameter may not be required.
import { xbl } from '@xboxreplay/xboxlive-auth';
const userTokenExchangeResponse = {
IssueInstant: '2021-01-14T18:55:20.0082007Z',
NotAfter: '2021-01-15T10:55:20.0082007Z',
Token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
DisplayClaims: {
xui: [{ uhs: '3218841136841218711' }]
}
};
const deviceToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
const titleToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
const userToken = userTokenExchangeResponse.Token;
const XSTSTokenResponse = await xbl.exchangeTokensForXSTSToken({
userTokens: [userToken],
deviceToken,
titleToken
}, { sandboxId: 'RETAIL' });
console.info(XSTSTokenResponse);
- tokens {object}
- userTokens {string[]}
- deviceToken {string=}
- titleToken {string=}
- options {object=}
- XSTSRelyingParty {string=} -
http://xboxlive.com
- Targeted RelyingParty - optionalDisplayClaims {string[]=} -
[]
- Optional display claims to be returned based on the used RelyingParty - sandboxId {string=} -
RETAIL
- Targeted sandbox ID
- XSTSRelyingParty {string=} -
- additionalHeaders {object=} -
{}
- Additional headers if required, can be used to override default ones
{
"IssueInstant": "2021-01-14T18:55:20.0082007Z",
"NotAfter": "2021-01-15T10:55:20.0082007Z",
"Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"DisplayClaims": {
"xui": [{
"gtg": "Zeny IC",
"xid": "2584878536129841",
"uhs": "3218841136841218711",
"agg": "Adult",
"usr": "234",
"utr": "190",
"prv": "185 186 187 188 191 192 ..."
}]
}
}
Create a dummy Win32 deviceToken
that can be used during the authentication process.
Returns login.live.com
authorize URL.
import { live } from '@xboxreplay/xboxlive-auth';
const authorizeUrl = live.getAuthorizeUrl();
console.info(authorizeUrl);
- clientId {string=} -
000000004C12AE6F
- scope {string=} -
service::user.auth.xboxlive.com::MBI_SSL
- responseType {token|code=} -
token
- redirectUri {string=} -
https://login.live.com/oauth20_desktop.srf
https://login.live.com/oauth20_authorize.srf?client_id=000000004C12AE6F&redirect_uri=https://login.live.com/oauth20_desktop.srf&response_type=token&scope=service::user.auth.xboxlive.com::MBI_SSL
Refresh an expired token.
import { live } from '@xboxreplay/xboxlive-auth';
const freshTokens = await live.refreshAccessToken('M.R3_B.xxxxxx');
console.info(freshTokens);
- refreshToken {string}
- clientId {string=} -
000000004C12AE6F
- scope {string=} -
service::user.auth.xboxlive.com::MBI_SSL
- clientSecret {string=} -
undefined
{
"token_type": "bearer",
"expires_in": 86400,
"access_token": "EwAIA+pvBAAUK...", // RpsTicket
"refresh_token": "M.R3_BAY...",
"scope": "service::user.auth.xboxlive.com::MBI_SSL",
"user_id": "123abc..."
}
Authenticate with credentials.
import { live } from '@xboxreplay/xboxlive-auth';
const authResponse = await live.authenticate({
email: 'account@domain.com',
password: 'password'
});
console.info(authResponse);
- credentials {object}
- email {string}
- password {string}
{
"token_type": "bearer",
"expires_in": 86400,
"access_token": "EwAIA+pvBAAUK...", // RpsTicket
"refresh_token": "M.R3_BAY...",
"scope": "service::user.auth.xboxlive.com::MBI_SSL",
"user_id": "123abc..."
}