XboxAuthNet 3.0.0-beta.3
See the version list below for details.
dotnet add package XboxAuthNet --version 3.0.0-beta.3
NuGet\Install-Package XboxAuthNet -Version 3.0.0-beta.3
<PackageReference Include="XboxAuthNet" Version="3.0.0-beta.3" />
paket add XboxAuthNet --version 3.0.0-beta.3
#r "nuget: XboxAuthNet, 3.0.0-beta.3"
// Install XboxAuthNet as a Cake Addin #addin nuget:?package=XboxAuthNet&version=3.0.0-beta.3&prerelease // Install XboxAuthNet as a Cake Tool #tool nuget:?package=XboxAuthNet&version=3.0.0-beta.3&prerelease
XboxAuthNet
Microsoft OAuth 2.0 and Xbox Authentication
Features
- Microsoft OAuth Code Flow
- Xbox Authentication
- Xbox Sisu Authentication with Proof-of-Possession
Install
Usage: Microsoft OAuth
Currently only auth code flow is supported.
// Initialize API client
var httpClient = new HttpClient();
var apiClient = new MicrosoftOAuthCodeApiClient("<CLIENT-ID>", "<SCOPES>", httpClient); // replace "SCOPES" to XboxAuth.XboxScope for Xbox Authentication
// Authenticate with auth code flow
var codeFlow = new MicrosoftOAuthCodeFlowBuilder(apiClient)
.Build();
MicrosoftOAuthResponse result = await codeFlow.Authenticate();
// `result.AccessToken` can be used on Xbox Authentication
// store `result` variable to refresh token later.
// `MicrosoftOAuthResponse` can be serialized (like json)
Console.WriteLine(result.AccessToken);
Console.WriteLine(result.RefreshToken);
Refresh Microsoft OAuth Token
if (!result.Validate())
{
var newResult = await apiClient.RefreshToken(result.RefreshToken, CancellationToken.None);
Console.WriteLine(newResult.AccessToken);
Console.WriteLine(newResult.RefreshToken);
}
Usage: Xbox Authentication
There are three Xbox authentication methods. You can find a description of each method here.
Xbox Basic Authentication
var httpClient = new HttpClient();
var xboxAuthClient = new XboxAuthClient(httpClient);
var userToken = await xboxAuthClient.RequestUserToken("<microsoft_oauth2_access_token>");
var xsts = await xboxAuthClient.RequestXsts(userToken.Token, "<relying_party>");
Console.WriteLine(xsts.Token);
Xbox Full Authentication
var httpClient = new HttpClient();
var xboxAuthClient = new XboxAuthClient(httpClient);
var userToken = await xboxAuthClient.RequestSignedUserToken(new XboxSignedUserTokenRequest
{
AccessToken = "<microsoft_oauth2_access_token>",
TokenPrefix = AbstractXboxAuthRequest.XboxTokenPrefix
});
var deviceToken = await xboxAuthClient.RequestDeviceToken(new XboxDeviceTokenRequest
{
DeviceType = XboxDeviceTypes.Nintendo,
DeviceVersion = "0.0.0"
});
var titleToken = await xboxAuthClient.RequestTitleToken(new XboxTitleTokenRequest
{
AccessToken = "<microsoft_oauth2_access_token>",
DeviceToken = deviceToken.Token
});
var xsts = await xboxAuthClient.RequestXsts(new XboxXstsRequest
{
UserToken = userToken.Token,
DeviceToken = deviceToken.Token,
TitleToken = titleToken.Token,
RelyingParty = "<relying_party>"
});
Console.WriteLine(xsts.Token);
Xbox Sisu Authentication
var httpClient = new HttpClient();
var xboxAuthClient = new XboxAuthClient(httpClient);
var deviceToken = await xboxAuthClient.RequestDeviceToken(XboxDeviceTypes.Win32, "0.0.0");
var sisuResult = await xboxAuthClient.SisuAuth(new XboxSisuAuthRequest
{
AccessToken = "<microsoft_oauth2_access_token>",
ClientId = XboxGameTitles.MinecraftJava,
DeviceToken = deviceToken.Token,
RelyingParty = "<relying_party>"
});
Console.WriteLine(xsts.Token);
Example
References
These documents explain how Microsoft OAuth 2.0 works.
Desktop application calling a web api (XboxAuthNet implements interactive authentication)
This project was made possible thanks to the contributions of various open-source projects. not used any document from NDA developer program
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net5.0-windows7.0 is compatible. 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. |
.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 | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. 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.7.2
- Microsoft.Web.WebView2 (>= 1.0.1210.39)
- System.Net.Http.Json (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
-
.NETStandard 2.0
- System.Net.Http.Json (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
-
net5.0-windows7.0
- Microsoft.Web.WebView2 (>= 1.0.1210.39)
- System.Net.Http.Json (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XboxAuthNet:
Package | Downloads |
---|---|
XboxAuthNet.Game
XboxAuthNet.Game |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.4 | 678 | 8/21/2024 |
3.0.3 | 126 | 8/20/2024 |
3.0.2 | 2,555 | 7/7/2023 |
3.0.1 | 172 | 7/7/2023 |
3.0.0 | 1,074 | 6/24/2023 |
3.0.0-beta.3 | 203 | 4/2/2023 |
3.0.0-beta.2 | 171 | 2/4/2023 |
3.0.0-beta.1 | 136 | 1/5/2023 |
2.2.0 | 3,080 | 9/7/2022 |
2.2.0-beta8 | 315 | 8/31/2022 |
2.1.0 | 1,575 | 7/29/2022 |
2.0.0 | 1,249 | 7/8/2022 |
2.0.0-beta1 | 166 | 5/29/2022 |
1.4.2 | 2,512 | 10/5/2021 |
1.4.1 | 666 | 8/22/2021 |
1.4.0 | 464 | 7/4/2021 |
1.3.0 | 506 | 12/28/2020 |
1.2.0 | 390 | 12/25/2020 |
1.1.0 | 425 | 12/14/2020 |
1.0.2 | 374 | 12/13/2020 |
1.0.1 | 469 | 12/13/2020 |
1.0.0 | 460 | 12/13/2020 |