Skip to content

Commit

Permalink
Merge pull request #38 from henrikfroehling/GH-36
Browse files Browse the repository at this point in the history
Resolved GH-36
  • Loading branch information
henrikfroehling committed Jul 27, 2018
2 parents 2fc17cd + 9ab07b7 commit 9a4fec6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 463 deletions.
2 changes: 1 addition & 1 deletion Source/Lib/Trakt.NET/Modules/TraktAuthenticationModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public Task<TraktResponse<ITraktAuthorization>> PollForAuthorizationAsync(ITrakt
}

public Task<TraktResponse<ITraktAuthorization>> RefreshAuthorizationAsync(CancellationToken cancellationToken = default)
=> RefreshAuthorizationAsync(Authorization.RefreshToken, cancellationToken);
=> RefreshAuthorizationAsync(Authorization?.RefreshToken, cancellationToken);

public Task<TraktResponse<ITraktAuthorization>> RefreshAuthorizationAsync(string refreshToken, CancellationToken cancellationToken = default)
=> RefreshAuthorizationAsync(refreshToken, ClientId, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@ internal abstract class AAuthorizationRequest<TResponseContentType, TRequestBody
public override TRequestBodyType RequestBody { get; set; }

public override IDictionary<string, object> GetUriPathParameters() => new Dictionary<string, object>();

public override void Validate()
{
base.Validate();
RequestBody.Validate();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,5 @@ internal sealed class AuthorizationRevokeRequest : APostRequest<AuthorizationRev
public override AuthorizationRevokeRequestBody RequestBody { get; set; }

public override IDictionary<string, object> GetUriPathParameters() => new Dictionary<string, object>();

public override void Validate()
{
base.Validate();
RequestBody.Validate();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,23 +247,8 @@ public async Task<TraktResponse<ITraktAuthorization>> PollForAuthorizationAsync(
}
}

public async Task<TraktResponse<ITraktAuthorization>> RefreshAuthorizationAsync(AuthorizationRefreshRequest request, CancellationToken cancellationToken = default)
{
try
{
if (!_client.Authentication.IsAuthorized)
throw new TraktAuthorizationException("not authorized");
}
catch (Exception ex)
{
if (_client.Configuration.ThrowResponseExceptions)
throw;

return new TraktResponse<ITraktAuthorization> { IsSuccess = false, Exception = ex };
}

return await ExecuteAuthorizationRequestAsync(request, true, cancellationToken).ConfigureAwait(false);
}
public Task<TraktResponse<ITraktAuthorization>> RefreshAuthorizationAsync(AuthorizationRefreshRequest request, CancellationToken cancellationToken = default)
=> ExecuteAuthorizationRequestAsync(request, true, cancellationToken);

public async Task<TraktNoContentResponse> RevokeAuthorizationAsync(AuthorizationRevokeRequest request, string clientId, CancellationToken cancellationToken = default)
{
Expand Down
Loading

0 comments on commit 9a4fec6

Please sign in to comment.