From bcc81b846286a846518eafa7fdf3b32d9b02034e Mon Sep 17 00:00:00 2001
From: AiiR <22158489+ImAiiR@users.noreply.github.com>
Date: Mon, 10 Aug 2020 15:25:26 -0400
Subject: [PATCH] 0.9.9.20

- Fixed login
---
 QobuzDownloaderX/LoginForm-v2.cs            | 15 +++++++++++++--
 QobuzDownloaderX/Properties/AssemblyInfo.cs |  4 ++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/QobuzDownloaderX/LoginForm-v2.cs b/QobuzDownloaderX/LoginForm-v2.cs
index 4c312c5..3edda85 100644
--- a/QobuzDownloaderX/LoginForm-v2.cs
+++ b/QobuzDownloaderX/LoginForm-v2.cs
@@ -447,16 +447,27 @@ namespace QobuzDownloaderX
         {
             loginBG.WorkerSupportsCancellation = true;
 
-            // Create HttpClient to grab Track ID
+            // Create HttpClient for logging in using Napster / Rhapsody API. 
             var loginClient = new HttpClient();
+            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; //Make connection secure
+            loginClient.DefaultRequestHeaders.Add("Authorization", "Basic WlRKbE9XTmhaR1V0TnpsbVpTMDBaR1UyTFRrd1lqTXRaRGsxT0RSbE1Ea3dPRE01Ok1UUmpaVFZqTTJFdE9HVmxaaTAwT1RVM0xXRm1Oamt0TlRsbE9ERmhObVl5TnpJNQ=="); //This value is from logging in to the Napster Android app.
+
+            
+
+            // Create HttpClient to grab Track ID
+            var loginClient2 = new HttpClient();
             // Run through TLS to allow secure connection.
             ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
             // Set user-agent to Firefox.
             loginClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0");
 
+            var loginURL = "https://www.qobuz.com/api.json/0.2/user/login"; //Set base URL
+            var parameters = new Dictionary<string, string> { { "username", emailTextbox.Text }, { "email", emailTextbox.Text }, { "password", passwordTextbox.Text }, { "extra", "partner" }, { "app_id", appID } }; //Set email & password parameters
+            var encodedContent = new FormUrlEncodedContent(parameters); //Add parameters as encoded content to login
+
             // Grab response from Rhapsody to get Track IDs from Album response.
             var loginUrl = "https://www.qobuz.com/api.json/0.2/user/login?email=" + emailTextbox.Text + "&password=" + passwordTextbox.Text + "&app_id=" + appID;
-            var loginResponse = await loginClient.GetAsync(loginUrl);
+            var loginResponse = await loginClient.PostAsync(loginURL, encodedContent);
             string loginResponseString = loginResponse.Content.ReadAsStringAsync().Result;
 
             // Grab metadata from API JSON response
diff --git a/QobuzDownloaderX/Properties/AssemblyInfo.cs b/QobuzDownloaderX/Properties/AssemblyInfo.cs
index 1771cf8..0fcb6bd 100644
--- a/QobuzDownloaderX/Properties/AssemblyInfo.cs
+++ b/QobuzDownloaderX/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.9.9.19")]
-[assembly: AssemblyFileVersion("0.9.9.19")]
+[assembly: AssemblyVersion("0.9.9.20")]
+[assembly: AssemblyFileVersion("0.9.9.20")]