OpenXbox.XboxWebApi 0.2.5

Unoffical C# Xbox WebAPI, includes support for authentication with Windows Live / Xbox Live.

Install-Package OpenXbox.XboxWebApi -Version 0.2.5
dotnet add package OpenXbox.XboxWebApi --version 0.2.5
<PackageReference Include="OpenXbox.XboxWebApi" Version="0.2.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenXbox.XboxWebApi --version 0.2.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Xbox WebAPI library for .NET

Build status
NuGet
Discord

C# Xbox WebAPI, includes support for authentication with Windows Live / Xbox Live.

Usage

Basic authentication flow

using System;
using XboxWebApi.Authentication;
using XboxWebApi.Authentication.Model;

// ...

string requestUrl = AuthenticationService.GetWindowsLiveAuthenticationUrl();

/* Call requestUrl via WebWidget or manually and authenticate */

WindowsLiveResponse response = AuthenticationService.ParseWindowsLiveResponse(
    "<Received Redirection URL>");

AuthenticationService authenticator = new AuthenticationService(response);

if (!authenticator.Authenticate())
    throw new Exception("Authentication failed!");

Console.WriteLine(authenticator.XToken);
Console.WriteLine(authenticator.UserInformation);

Save token to JSON

using System.IO;
using XboxWebApi.Common;

FileStream fs = new FileStream("tokens.json", FileMode.Create);
authenticator.DumpToFile(fs);
fs.Close();

Load token from JSON

using System.IO;
using XboxWebApi.Common;
using XboxWebApi.Authentication;

FileStream fs = new FileStream("tokens.json", FileMode.Open);
AuthenticationService authenticator = AuthenticationService.LoadFromFile(fs);
fs.Close();

Example Api Usage

using System;
using XboxWebApi.Common;
using XboxWebApi.Extensions;
using XboxWebApi.Services;
using XboxWebApi.Services.Api;
using XboxWebApi.Services.Model;

if (!authenticator.XToken.Valid)
{
    Console.WriteLine("Token expired, please refresh / reauthenticate");
    return;
}

XblConfiguration xblConfig = new XblConfiguration(authenticator.XToken, XblLanguage.United_States);

PresenceService presenceService = new PresenceService(xblConfig);
PeopleService peopleService = new PeopleService(xblConfig);
MessageService messageService = new MessageService(xblConfig);
// ... more services

var friends = peopleService.GetFriends();
var presenceBatch = presenceService.GetPresenceBatch(friends.GetXuids());
for (int i=0; i < friends.TotalCount; i++)
{
    Console.WriteLine($"{presenceBatch[i].Xuid} is {presenceBatch[i].State}");
}

Documentation

Not yet, please look at XboxWebApi.Tests for now.

Credits

Informations on endpoints gathered from:

Disclaimer

Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation.
Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or
any associated subsidiaries, logos or trademarks.

Xbox WebAPI library for .NET

Build status
NuGet
Discord

C# Xbox WebAPI, includes support for authentication with Windows Live / Xbox Live.

Usage

Basic authentication flow

using System;
using XboxWebApi.Authentication;
using XboxWebApi.Authentication.Model;

// ...

string requestUrl = AuthenticationService.GetWindowsLiveAuthenticationUrl();

/* Call requestUrl via WebWidget or manually and authenticate */

WindowsLiveResponse response = AuthenticationService.ParseWindowsLiveResponse(
    "<Received Redirection URL>");

AuthenticationService authenticator = new AuthenticationService(response);

if (!authenticator.Authenticate())
    throw new Exception("Authentication failed!");

Console.WriteLine(authenticator.XToken);
Console.WriteLine(authenticator.UserInformation);

Save token to JSON

using System.IO;
using XboxWebApi.Common;

FileStream fs = new FileStream("tokens.json", FileMode.Create);
authenticator.DumpToFile(fs);
fs.Close();

Load token from JSON

using System.IO;
using XboxWebApi.Common;
using XboxWebApi.Authentication;

FileStream fs = new FileStream("tokens.json", FileMode.Open);
AuthenticationService authenticator = AuthenticationService.LoadFromFile(fs);
fs.Close();

Example Api Usage

using System;
using XboxWebApi.Common;
using XboxWebApi.Extensions;
using XboxWebApi.Services;
using XboxWebApi.Services.Api;
using XboxWebApi.Services.Model;

if (!authenticator.XToken.Valid)
{
    Console.WriteLine("Token expired, please refresh / reauthenticate");
    return;
}

XblConfiguration xblConfig = new XblConfiguration(authenticator.XToken, XblLanguage.United_States);

PresenceService presenceService = new PresenceService(xblConfig);
PeopleService peopleService = new PeopleService(xblConfig);
MessageService messageService = new MessageService(xblConfig);
// ... more services

var friends = peopleService.GetFriends();
var presenceBatch = presenceService.GetPresenceBatch(friends.GetXuids());
for (int i=0; i < friends.TotalCount; i++)
{
    Console.WriteLine($"{presenceBatch[i].Xuid} is {presenceBatch[i].State}");
}

Documentation

Not yet, please look at XboxWebApi.Tests for now.

Credits

Informations on endpoints gathered from:

Disclaimer

Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation.
Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or
any associated subsidiaries, logos or trademarks.

Release Notes

Add WindowsLiveConstants and add asyncness to authentication

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.2.5 361 12/16/2018
0.2.4 827 12/2/2018
0.2.3 231 10/27/2018
0.2.2 140 10/26/2018
0.2.1 205 6/8/2018
0.2.0 210 6/7/2018
0.1.0 215 6/3/2018