From e7583ae34f172508fc2aa2aa71628b64459a0a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=E2=96=88=E2=96=88=E2=96=88=E2=96=88=E2=96=88?= Date: Wed, 1 Oct 2025 12:19:00 -0400 Subject: [PATCH] chore: update --- src/Nullinside.TwitchStreamingTools/Configuration.cs | 3 ++- src/Nullinside.TwitchStreamingTools/IConfiguration.cs | 3 ++- .../Services/ITwitchAccountService.cs | 3 ++- .../Services/TwitchAccountService.cs | 7 ++++--- .../Utilities/TwitchApiWrapper.cs | 7 ++++--- .../ViewModels/Pages/AccountViewModel.cs | 5 +++-- src/nullinside-api | 2 +- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Nullinside.TwitchStreamingTools/Configuration.cs b/src/Nullinside.TwitchStreamingTools/Configuration.cs index a1260a9..a91fa31 100644 --- a/src/Nullinside.TwitchStreamingTools/Configuration.cs +++ b/src/Nullinside.TwitchStreamingTools/Configuration.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Twitch; using Nullinside.TwitchStreamingTools.Controls.ViewModels; using Nullinside.TwitchStreamingTools.Models; @@ -55,7 +56,7 @@ public static Configuration Instance { /// /// The twitch OAuth token. /// - public TwitchAccessToken? OAuth { get; set; } + public OAuthToken? OAuth { get; set; } /// /// The twitch application configuration for getting OAuth tokens. diff --git a/src/Nullinside.TwitchStreamingTools/IConfiguration.cs b/src/Nullinside.TwitchStreamingTools/IConfiguration.cs index 6d6e650..0c1b511 100644 --- a/src/Nullinside.TwitchStreamingTools/IConfiguration.cs +++ b/src/Nullinside.TwitchStreamingTools/IConfiguration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Twitch; using Nullinside.TwitchStreamingTools.Controls.ViewModels; using Nullinside.TwitchStreamingTools.Models; @@ -18,7 +19,7 @@ public interface IConfiguration { /// /// The twitch OAuth token. /// - TwitchAccessToken? OAuth { get; set; } + OAuthToken? OAuth { get; set; } /// /// The twitch application configuration for getting OAuth tokens. diff --git a/src/Nullinside.TwitchStreamingTools/Services/ITwitchAccountService.cs b/src/Nullinside.TwitchStreamingTools/Services/ITwitchAccountService.cs index 83f8030..7a46c82 100644 --- a/src/Nullinside.TwitchStreamingTools/Services/ITwitchAccountService.cs +++ b/src/Nullinside.TwitchStreamingTools/Services/ITwitchAccountService.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Twitch; namespace Nullinside.TwitchStreamingTools.Services; @@ -27,7 +28,7 @@ public interface ITwitchAccountService { /// /// An event indicating that the credentials have changed. /// - Action? OnCredentialsChanged { get; set; } + Action? OnCredentialsChanged { get; set; } /// /// Updates the credentials. diff --git a/src/Nullinside.TwitchStreamingTools/Services/TwitchAccountService.cs b/src/Nullinside.TwitchStreamingTools/Services/TwitchAccountService.cs index 58dd405..317aa16 100644 --- a/src/Nullinside.TwitchStreamingTools/Services/TwitchAccountService.cs +++ b/src/Nullinside.TwitchStreamingTools/Services/TwitchAccountService.cs @@ -3,6 +3,7 @@ using Avalonia.Threading; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Twitch; using Nullinside.TwitchStreamingTools.Utilities; @@ -55,11 +56,11 @@ public TwitchAccountService(ITwitchClientProxy twitchClient, IConfiguration conf public Action? OnCredentialsStatusChanged { get; set; } /// - public Action? OnCredentialsChanged { get; set; } + public Action? OnCredentialsChanged { get; set; } /// public async Task UpdateCredentials(string bearer, string refresh, DateTime expires) { - var oauth = new TwitchAccessToken { + var oauth = new OAuthToken { AccessToken = bearer, RefreshToken = refresh, ExpiresUtc = expires @@ -159,7 +160,7 @@ private async Task DoTokenRefreshIfNearExpiration() { await twitchApi.RefreshAccessToken().ConfigureAwait(false); // Update the configuration - _configuration.OAuth = new TwitchAccessToken { + _configuration.OAuth = new OAuthToken { AccessToken = twitchApi.OAuth.AccessToken, RefreshToken = twitchApi.OAuth.RefreshToken, ExpiresUtc = twitchApi.OAuth.ExpiresUtc ?? DateTime.MinValue diff --git a/src/Nullinside.TwitchStreamingTools/Utilities/TwitchApiWrapper.cs b/src/Nullinside.TwitchStreamingTools/Utilities/TwitchApiWrapper.cs index fa0f7c5..6d0b9d2 100644 --- a/src/Nullinside.TwitchStreamingTools/Utilities/TwitchApiWrapper.cs +++ b/src/Nullinside.TwitchStreamingTools/Utilities/TwitchApiWrapper.cs @@ -8,6 +8,7 @@ using Newtonsoft.Json; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Twitch; namespace Nullinside.TwitchStreamingTools.Utilities; @@ -38,7 +39,7 @@ public TwitchApiWrapper() : base( /// /// The refresh token. /// The new OAuth token information if successful, null otherwise. - public override async Task RefreshAccessToken(CancellationToken token = new()) { + public override async Task RefreshAccessToken(CancellationToken token = new()) { try { // If the secret is specified, then this isn't using our API to authenticate, it's using the twitch api directly. if (!string.IsNullOrWhiteSpace(TwitchAppConfig?.ClientSecret)) { @@ -53,12 +54,12 @@ public TwitchApiWrapper() : base( using HttpResponseMessage response = await client.PostAsync(request.RequestUri, content, token).ConfigureAwait(false); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(token).ConfigureAwait(false); - var oauthResp = JsonConvert.DeserializeObject(responseBody); + var oauthResp = JsonConvert.DeserializeObject(responseBody); if (null == oauthResp) { return null; } - return new TwitchAccessToken { + return new OAuthToken { AccessToken = oauthResp.AccessToken, ExpiresUtc = oauthResp.ExpiresUtc, RefreshToken = oauthResp.RefreshToken diff --git a/src/Nullinside.TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs b/src/Nullinside.TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs index 1f56455..29f63d1 100644 --- a/src/Nullinside.TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs +++ b/src/Nullinside.TwitchStreamingTools/ViewModels/Pages/AccountViewModel.cs @@ -16,6 +16,7 @@ using Newtonsoft.Json; using Nullinside.Api.Common; +using Nullinside.Api.Common.Auth; using Nullinside.Api.Common.Extensions; using Nullinside.Api.Common.Twitch; using Nullinside.TwitchStreamingTools.Services; @@ -145,7 +146,7 @@ private async Task LoadProfileImage() { /// Called when the credentials are changed to load the new profile image. /// /// - private async void OnCredentialsChanged(TwitchAccessToken? token) { + private async void OnCredentialsChanged(OAuthToken? token) { try { if (string.IsNullOrWhiteSpace(token?.AccessToken)) { ProfileImage = null; @@ -213,7 +214,7 @@ private async Task PerformLogin() { await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Completed Successfully!", token).ConfigureAwait(false); // Update the oauth token in the twitch account service. - var oauthResp = JsonConvert.DeserializeObject(json); + var oauthResp = JsonConvert.DeserializeObject(json); if (null == oauthResp || null == oauthResp.AccessToken || null == oauthResp.RefreshToken || null == oauthResp.ExpiresUtc) { _logger.Error($"Failed to get a valid oauth token, got: {json}"); return; diff --git a/src/nullinside-api b/src/nullinside-api index 76a3c69..a078ee9 160000 --- a/src/nullinside-api +++ b/src/nullinside-api @@ -1 +1 @@ -Subproject commit 76a3c6984cea20bf75ea6814f342ab2403cff20a +Subproject commit a078ee91467f84f13d9ae9341e2aee698fd78dfe