Skip to content

Repository files navigation

Xbox WebAPI library for .NET

GitHub Workflow - BuildNuGetDiscord

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

Usage

Basic authentication flow

usingSystem;usingXboxWebApi.Authentication;usingXboxWebApi.Authentication.Model;// ...stringrequestUrl=AuthenticationService.GetWindowsLiveAuthenticationUrl();/* Call requestUrl via WebWidget or manually and authenticate */WindowsLiveResponseresponse=AuthenticationService.ParseWindowsLiveResponse("<Received Redirection URL>");AuthenticationServiceauthenticator=newAuthenticationService(response);stringtokenFilePath="tokens.json";boolsuccess=awaitauthenticator.AuthenticateAsync();if(!success)thrownewException("Authentication failed!");success=awaitauthenticator.DumpToJsonFileAsync(tokenFilePath);if(!success)thrownewException("Failed to dump tokens");Console.WriteLine("Tokens saved to {}",tokenFilePath);Console.WriteLine(authenticator.XToken);Console.WriteLine(authenticator.UserInformation);

Save token to JSON

usingXboxWebApi.Authentication;awaitauthenticator.DumpToJsonFileAsync(tokenFilePath);

Load token from JSON

usingXboxWebApi.Authentication;AuthenticationServiceauthenticator=awaitAuthenticationService.LoadFromJsonFileAsync("tokens.json");

Example Api Usage

usingSystem;usingXboxWebApi.Common;usingXboxWebApi.Services;usingXboxWebApi.Services.Api;usingXboxWebApi.Services.Model;usingXboxWebApi.Authentication;if(!authenticator.XToken.Valid){Console.WriteLine("Token expired, please refresh / reauthenticate");return;}XblConfigurationxblConfig=newXblConfiguration(authenticator.XToken,XblLanguage.United_States);PresenceServicepresenceService=newPresenceService(xblConfig);PeopleServicepeopleService=newPeopleService(xblConfig);MessageServicemessageService=newMessageService(xblConfig);// ... more servicesvarfriends=awaitpeopleService.GetFriendsAsync();varpresenceBatch=awaitpresenceService.GetPresenceBatchAsync(friends.GetXuids());for(inti=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.

About

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

Resources

Stars

65 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages