This commit is contained in:
Jonas Dellinger 2018-09-04 14:41:35 +02:00
parent 2f8bf6877f
commit a302694da8
2 changed files with 13 additions and 11 deletions

View File

@ -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, "/")]

View File

@ -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<bool> GetAuth(WebServer server, HttpListenerContext context)
{
string state = context.Request.QueryString["state"];
SpotifyAuthServer<Token> 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");
}
}
}