From 36ad4fff0248110bf80f5f6bcdd767fb3e07c990 Mon Sep 17 00:00:00 2001 From: Martin Barker Date: Sat, 28 Jan 2023 00:39:34 +0000 Subject: [PATCH] Added Protection for the Twitch Secrets --- Readme.md | 16 +++++++-------- .../Core/TwitchFetcher.cs | 20 ++++++++----------- .../TwitchDesktopNotifications.csproj | 4 +++- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Readme.md b/Readme.md index 5958f75..51dc1a7 100644 --- a/Readme.md +++ b/Readme.md @@ -13,15 +13,13 @@ Want to contribute? Great! Project is built using Visual Studios 2022, must have Windows 10.0.17763 SDK installed -You must create a `App.config` file inside `TwitchDesktopNotifications` project. -```xml - - - - - - - +You need to create Application to obtain a ID and Secret on [Twitch Developer Console](https://dev.twitch.tv/console) once you have them +Open the project in Visual Studio 2022 go to the Developer Powershell and then run the following commands, remembering to replace the `{You Twitch Applciations Client ID}` and `{You Twitch Applciations Client Secret}` with the appropriate information from your [Twitch Developer Console](https://dev.twitch.tv/console) +```pwsh +cd TwitchDesktopNotifications +dotnet user-secrets init +dotnet user-secret set TwitchClientID {You Twitch Applciation's Client ID} +dotnet user-secret set TwitchClientSecret {You Twitch Applciation's Client Secret} ``` ## License diff --git a/TwitchDesktopNotifications/Core/TwitchFetcher.cs b/TwitchDesktopNotifications/Core/TwitchFetcher.cs index 2646c72..236b3e6 100644 --- a/TwitchDesktopNotifications/Core/TwitchFetcher.cs +++ b/TwitchDesktopNotifications/Core/TwitchFetcher.cs @@ -1,32 +1,28 @@ using ABI.System; -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Configuration; +using Microsoft.Extensions.Configuration; using System.Diagnostics; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Text.Json; -using System.Text.Json.Nodes; -using System.Threading.Tasks; using System.Web; using TwitchDesktopNotifications.JsonStructure; using TwitchDesktopNotifications.JsonStructure.Helix; -using Windows.ApplicationModel.Background; namespace TwitchDesktopNotifications.Core { internal class TwitchFetcher { - private TwitchFetcher() { } + private TwitchFetcher() { + var config = new ConfigurationBuilder().AddUserSecrets().Build(); + TwitchClientID = config["TwitchClientID"]; + TwitchClientSecret = config["TwitchClientSecret"]; + } public static TwitchFetcher instance { get; private set; } - string TwitchClientID = ConfigurationManager.AppSettings["TwitchClientID"]; - string TwitchClientSecret = ConfigurationManager.AppSettings["TwitchClientSecret"]; + string TwitchClientID = ""; + string TwitchClientSecret = ""; List currentlyLive = null; diff --git a/TwitchDesktopNotifications/TwitchDesktopNotifications.csproj b/TwitchDesktopNotifications/TwitchDesktopNotifications.csproj index 48de116..67760b6 100644 --- a/TwitchDesktopNotifications/TwitchDesktopNotifications.csproj +++ b/TwitchDesktopNotifications/TwitchDesktopNotifications.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -11,6 +11,7 @@ Twitch Notify True True + 2dfb7064-609b-41c3-a80d-a9e4d842a55d @@ -18,6 +19,7 @@ +