Skip to content

Commit 3917fbe

Browse files
author
Jonas Dellinger
committed
Code Cleanup and ImplictGrantAuth name fix, fixes #320
1 parent 278927f commit 3917fbe

32 files changed

Lines changed: 118 additions & 167 deletions

SpotifyAPI.Web.Auth/AuthUtil.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public static void OpenBrowser(string url)
2121
{
2222
Process.Start("open", url);
2323
}
24-
else
25-
{
26-
// throw
27-
}
2824
#else
2925
url = url.Replace("&", "^&");
3026
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));

SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Net;
43
using System.Net.Http;
54
using System.Text;
65
using System.Threading.Tasks;
@@ -48,7 +47,7 @@ protected override void AdaptWebServer(WebServer webServer)
4847

4948
public async Task<Token> RefreshToken(string refreshToken)
5049
{
51-
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
50+
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
5251
{
5352
new KeyValuePair<string, string>("grant_type", "refresh_token"),
5453
new KeyValuePair<string, string>("refresh_token", refreshToken)
@@ -65,7 +64,7 @@ public async Task<Token> RefreshToken(string refreshToken)
6564
}
6665
public async Task<Token> ExchangeCode(string code)
6766
{
68-
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
67+
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
6968
{
7069
new KeyValuePair<string, string>("grant_type", "authorization_code"),
7170
new KeyValuePair<string, string>("code", code),

SpotifyAPI.Web.Auth/CredentialsAuth.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Net;
43
using System.Net.Http;
54
using System.Text;
65
using System.Threading.Tasks;
@@ -25,7 +24,7 @@ public async Task<Token> GetToken()
2524
{
2625
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
2726

28-
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>()
27+
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
2928
{
3029
new KeyValuePair<string, string>("grant_type", "client_credentials")
3130
};
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
1-
using System;
2-
using System.Net;
31
using System.Threading.Tasks;
42
using SpotifyAPI.Web.Enums;
53
using SpotifyAPI.Web.Models;
64
using Unosquare.Labs.EmbedIO;
75
using Unosquare.Labs.EmbedIO.Constants;
86
using Unosquare.Labs.EmbedIO.Modules;
9-
#if NETSTANDARD2_0
10-
using System.Net.Http;
11-
#endif
12-
#if NET46
13-
using System.Net.Http;
14-
using HttpListenerContext = Unosquare.Net.HttpListenerContext;
15-
#endif
167

178
namespace SpotifyAPI.Web.Auth
189
{
19-
public class ImplictGrantAuth : SpotifyAuthServer<Token>
10+
public class ImplicitGrantAuth : SpotifyAuthServer<Token>
2011
{
21-
public ImplictGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
12+
public ImplicitGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
2213
base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
2314
{
2415
ClientId = clientId;
2516
}
2617

2718
protected override void AdaptWebServer(WebServer webServer)
2819
{
29-
webServer.Module<WebApiModule>().RegisterController<ImplictGrantAuthController>();
20+
webServer.Module<WebApiModule>().RegisterController<ImplicitGrantAuthController>();
3021
}
3122
}
3223

33-
public class ImplictGrantAuthController : WebApiController
24+
public class ImplicitGrantAuthController : WebApiController
3425
{
3526
[WebApiHandler(HttpVerbs.Get, "/auth")]
3627
public Task<bool> GetAuth()
3728
{
3829
string state = Request.QueryString["state"];
39-
SpotifyAuthServer<Token> auth = ImplictGrantAuth.GetByState(state);
30+
SpotifyAuthServer<Token> auth = ImplicitGrantAuth.GetByState(state);
4031
if (auth == null)
4132
return this.StringResponseAsync(
4233
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");
@@ -57,7 +48,7 @@ public Task<bool> GetAuth()
5748
}
5849
else
5950
{
60-
token = new Token()
51+
token = new Token
6152
{
6253
Error = error
6354
};
@@ -67,7 +58,7 @@ public Task<bool> GetAuth()
6758
return this.StringResponseAsync("OK - This window can be closed now");
6859
}
6960

70-
public ImplictGrantAuthController(IHttpContext context) : base(context)
61+
public ImplicitGrantAuthController(IHttpContext context) : base(context)
7162
{
7263
}
7364
}

SpotifyAPI.Web.Auth/SpotifyAuthServer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading;
77
using SpotifyAPI.Web.Enums;
88
using Unosquare.Labs.EmbedIO;
9-
using Unosquare.Labs.EmbedIO.Constants;
109
using Unosquare.Labs.EmbedIO.Modules;
1110

1211
namespace SpotifyAPI.Web.Auth

SpotifyAPI.Web.Example/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ internal static class Program
1010
private static string _clientId = ""; //"";
1111
private static string _secretId = ""; //"";
1212

13+
// ReSharper disable once UnusedParameter.Local
1314
static void Main(string[] args)
1415
{
1516
_clientId = string.IsNullOrEmpty(_clientId)

SpotifyAPI.Web.Tests/SpotifyWebAPITest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class SpotifyWebAPITest
2121
public void SetUp()
2222
{
2323
_mock = new Mock<IClient>();
24-
_spotify = new SpotifyWebAPI()
24+
_spotify = new SpotifyWebAPI
2525
{
2626
WebClient = _mock.Object,
2727
UseAuth = false

SpotifyAPI.Web/Models/BasicModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using Newtonsoft.Json;
2-
using SpotifyAPI.Web.Enums;
3-
using System;
42
using System.Net;
53

64
namespace SpotifyAPI.Web.Models

SpotifyAPI.Web/Models/Category.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Newtonsoft.Json;
2-
using System;
32
using System.Collections.Generic;
43

54
namespace SpotifyAPI.Web.Models

SpotifyAPI.Web/Models/CursorPaging.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Newtonsoft.Json;
2-
using System;
32
using System.Collections.Generic;
43

54
namespace SpotifyAPI.Web.Models

0 commit comments

Comments
 (0)