Added Protection for the Twitch Secrets

This commit is contained in:
Martin Barker
2023-01-28 00:39:34 +00:00
parent ac4b022587
commit 36ad4fff02
3 changed files with 18 additions and 22 deletions

View File

@@ -13,15 +13,13 @@ Want to contribute? Great!
Project is built using Visual Studios 2022, must have Windows 10.0.17763 SDK installed 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. You need to create Application to obtain a ID and Secret on [Twitch Developer Console](https://dev.twitch.tv/console) once you have them
```xml 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)
<?xml version="1.0" encoding="utf-8" ?> ```pwsh
<configuration> cd TwitchDesktopNotifications
<appSettings> dotnet user-secrets init
<add key="TwitchClientID" value="" /> dotnet user-secret set TwitchClientID {You Twitch Applciation's Client ID}
<add key="TwitchClientSecret" value="" /> dotnet user-secret set TwitchClientSecret {You Twitch Applciation's Client Secret}
</appSettings>
</configuration>
``` ```
## License ## License

View File

@@ -1,32 +1,28 @@
using ABI.System; using ABI.System;
using System; using Microsoft.Extensions.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using System.Web; using System.Web;
using TwitchDesktopNotifications.JsonStructure; using TwitchDesktopNotifications.JsonStructure;
using TwitchDesktopNotifications.JsonStructure.Helix; using TwitchDesktopNotifications.JsonStructure.Helix;
using Windows.ApplicationModel.Background;
namespace TwitchDesktopNotifications.Core namespace TwitchDesktopNotifications.Core
{ {
internal class TwitchFetcher internal class TwitchFetcher
{ {
private TwitchFetcher() { } private TwitchFetcher() {
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
TwitchClientID = config["TwitchClientID"];
TwitchClientSecret = config["TwitchClientSecret"];
}
public static TwitchFetcher instance { get; private set; } public static TwitchFetcher instance { get; private set; }
string TwitchClientID = ConfigurationManager.AppSettings["TwitchClientID"]; string TwitchClientID = "";
string TwitchClientSecret = ConfigurationManager.AppSettings["TwitchClientSecret"]; string TwitchClientSecret = "";
List <StreamsData> currentlyLive = null; List <StreamsData> currentlyLive = null;

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
@@ -11,6 +11,7 @@
<AssemblyName>Twitch Notify</AssemblyName> <AssemblyName>Twitch Notify</AssemblyName>
<UseWPF>True</UseWPF> <UseWPF>True</UseWPF>
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<UserSecretsId>2dfb7064-609b-41c3-a80d-a9e4d842a55d</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -18,6 +19,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="8.0.0-build.65" /> <PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="8.0.0-build.65" />
</ItemGroup> </ItemGroup>