public Task <bool> GetAuth() { string state = Request.QueryString["state"]; SpotifyAuthServer <AuthorizationCode> auth = TokenSwapAuth.GetByState(state); string code = null; string error = Request.QueryString["error"]; if (error == null) { code = Request.QueryString["code"]; } Task.Factory.StartNew(() => auth?.TriggerAuth(new AuthorizationCode { Code = code, Error = error })); return(this.StringResponseAsync(((TokenSwapAuth)auth).HtmlResponse)); }
public Task <bool> GetAuth(WebServer server, HttpListenerContext context) { string state = context.Request.QueryString["state"]; SpotifyAuthServer <Token> auth = ImplictGrantAuth.GetByState(state); if (auth == null) { return(context.StringResponseAsync( $"Failed - Unable to find auth request with state \"{state}\" - Please retry")); } Token token; string error = context.Request.QueryString["error"]; if (error == null) { string accessToken = context.Request.QueryString["access_token"]; string tokenType = context.Request.QueryString["token_type"]; string expiresIn = context.Request.QueryString["expires_in"]; token = new Token { AccessToken = accessToken, ExpiresIn = double.Parse(expiresIn), TokenType = tokenType }; } else { token = new Token() { Error = error }; } Task.Factory.StartNew(() => auth.TriggerAuth(token)); return(context.StringResponseAsync("OK - This window can be closed now")); }
public Task <bool> GetAuth() { string state = Request.QueryString["state"]; SpotifyAuthServer <Token> auth = ImplicitGrantAuth.GetByState(state); if (auth == null) { return(HttpContext.StringResponseAsync( $"Failed - Unable to find auth request with state \"{state}\" - Please retry")); } Token token; string error = Request.QueryString["error"]; if (error == null) { string accessToken = Request.QueryString["access_token"]; string tokenType = Request.QueryString["token_type"]; string expiresIn = Request.QueryString["expires_in"]; token = new Token { AccessToken = accessToken, ExpiresIn = double.Parse(expiresIn), TokenType = tokenType }; } else { token = new Token { Error = error }; } Task.Factory.StartNew(() => auth.TriggerAuth(token)); return(HttpContext.HtmlResponseAsync("<html><script type=\"text/javascript\">window.close();</script>OK - This window can be closed now</html>")); }