OpenXbox.XboxWebApi
0.2.5
See the version list below for details.
dotnet add package OpenXbox.XboxWebApi --version 0.2.5
NuGet\Install-Package OpenXbox.XboxWebApi -Version 0.2.5
<PackageReference Include="OpenXbox.XboxWebApi" Version="0.2.5" />
paket add OpenXbox.XboxWebApi --version 0.2.5
#r "nuget: OpenXbox.XboxWebApi, 0.2.5"
// Install OpenXbox.XboxWebApi as a Cake Addin #addin nuget:?package=OpenXbox.XboxWebApi&version=0.2.5 // Install OpenXbox.XboxWebApi as a Cake Tool #tool nuget:?package=OpenXbox.XboxWebApi&version=0.2.5
Xbox WebAPI library for .NET
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 11.0.2)
- RestSharp (>= 106.3.0)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 11.0.2)
- RestSharp (>= 106.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Add WindowsLiveConstants and add asyncness to authentication