diff --git a/FortnoxSDK/Auth/StandardAuthWorkflow.cs b/FortnoxSDK/Auth/StandardAuthWorkflow.cs index fdbd4ecc..d5f662e3 100644 --- a/FortnoxSDK/Auth/StandardAuthWorkflow.cs +++ b/FortnoxSDK/Auth/StandardAuthWorkflow.cs @@ -29,6 +29,15 @@ public TokenInfo GetToken(string authCode, string clientId, string clientSecret, public async Task GetTokenAsync(string authCode, string clientId, string clientSecret, string redirectUri = null) { + if (string.IsNullOrEmpty(authCode)) + throw new ArgumentException("Argument is null or empty.", nameof(authCode)); + + if (string.IsNullOrEmpty(clientId)) + throw new ArgumentException("Argument is null or empty.", nameof(clientId)); + + if (string.IsNullOrEmpty(clientSecret)) + throw new ArgumentException("Argument is null or empty.", nameof(clientSecret)); + var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{clientId}:{clientSecret}")); var request = new HttpRequestMessage(HttpMethod.Post, AuthTokenUri); @@ -56,6 +65,15 @@ public TokenInfo RefreshToken(string refreshToken, string clientId, string clien public async Task RefreshTokenAsync(string refreshToken, string clientId, string clientSecret) { + if (string.IsNullOrEmpty(refreshToken)) + throw new ArgumentException("Argument is null or empty.", nameof(refreshToken)); + + if (string.IsNullOrEmpty(clientId)) + throw new ArgumentException("Argument is null or empty.", nameof(clientId)); + + if (string.IsNullOrEmpty(clientSecret)) + throw new ArgumentException("Argument is null or empty.", nameof(clientSecret)); + var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{clientId}:{clientSecret}")); var request = new HttpRequestMessage(HttpMethod.Post, AuthTokenUri);