From a302694da894a05aed158597e0ab2036dea42b1a Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Tue, 4 Sep 2018 14:41:35 +0200 Subject: [PATCH] Cleanup --- SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs | 4 ---- SpotifyAPI.Web.Auth/ImplictGrantAuth.cs | 20 +++++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs b/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs index e9662868..ac531b34 100644 --- a/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs +++ b/SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs @@ -95,11 +95,7 @@ namespace SpotifyAPI.Web.Auth Error = error })); -#if NETSTANDARD2_0 return context.StringResponseAsync("OK - This window can be closed now"); -#else - return context.StringResponseAsync("OK - This window can be closed now"); -#endif } [WebApiHandler(HttpVerbs.Post, "/")] diff --git a/SpotifyAPI.Web.Auth/ImplictGrantAuth.cs b/SpotifyAPI.Web.Auth/ImplictGrantAuth.cs index 8cdf7a79..96487a60 100644 --- a/SpotifyAPI.Web.Auth/ImplictGrantAuth.cs +++ b/SpotifyAPI.Web.Auth/ImplictGrantAuth.cs @@ -6,6 +6,13 @@ using SpotifyAPI.Web.Models; using Unosquare.Labs.EmbedIO; using Unosquare.Labs.EmbedIO.Constants; using Unosquare.Labs.EmbedIO.Modules; +#if NETSTANDARD2_0 +using System.Net.Http; +#endif +#if NET46 +using System.Net.Http; +using HttpListenerContext = Unosquare.Net.HttpListenerContext; +#endif namespace SpotifyAPI.Web.Auth { @@ -27,14 +34,14 @@ namespace SpotifyAPI.Web.Auth public class ImplictGrantAuthController : WebApiController { - [WebApiHandler(HttpVerbs.Get, "/authe")] - public bool GetAuth(WebServer server, HttpListenerContext context) + [WebApiHandler(HttpVerbs.Get, "/auth")] + public Task GetAuth(WebServer server, HttpListenerContext context) { string state = context.Request.QueryString["state"]; SpotifyAuthServer auth = ImplictGrantAuth.GetByState(state); if (auth == null) - return true; /*context.StringResponseAsync( - $"Failed - Unable to find auth request with state \"{state}\" - Please retry");*/ + return context.StringResponseAsync( + $"Failed - Unable to find auth request with state \"{state}\" - Please retry"); Token token; string error = context.Request.QueryString["error"]; @@ -58,9 +65,8 @@ namespace SpotifyAPI.Web.Auth }; } - Task.Factory.StartNew(() => auth?.TriggerAuth(token)); - return true; - // return context.StringResponseAsync("OK - This window can be closed now"); + Task.Factory.StartNew(() => auth.TriggerAuth(token)); + return context.StringResponseAsync("OK - This window can be closed now"); } } }