2022-11-18 11:30:09 +00:00
|
|
|
using System.Threading;
|
2020-05-13 22:49:54 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
2020-05-30 22:20:42 +01:00
|
|
|
/// <summary>
|
|
|
|
/// An OAuth Client, which allows to get inital and updated tokens from the Spotify Service
|
|
|
|
/// </summary>
|
2020-05-13 22:49:54 +01:00
|
|
|
public interface IOAuthClient
|
|
|
|
{
|
2020-05-29 12:06:20 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Requests a new token using client_ids and client_secrets.
|
|
|
|
/// If the token is expired, simply call the funtion again to get a new token
|
|
|
|
/// </summary>
|
2020-06-02 22:55:50 +01:00
|
|
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
2022-11-18 11:30:09 +00:00
|
|
|
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
|
2020-05-30 22:20:42 +01:00
|
|
|
/// <remarks>
|
|
|
|
/// https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow
|
|
|
|
/// </remarks>
|
2020-05-29 12:06:20 +01:00
|
|
|
/// <returns></returns>
|
2022-11-18 11:30:09 +00:00
|
|
|
Task<ClientCredentialsTokenResponse> RequestToken(ClientCredentialsRequest request, CancellationToken cancel = default);
|
2020-05-29 12:06:20 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Refresh an already received token via Authorization Code Auth
|
|
|
|
/// </summary>
|
2020-06-02 22:55:50 +01:00
|
|
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
2022-11-18 11:30:09 +00:00
|
|
|
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
|
2020-05-30 22:20:42 +01:00
|
|
|
/// <remarks>
|
|
|
|
/// https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow
|
|
|
|
/// </remarks>
|
2020-05-29 12:06:20 +01:00
|
|
|
/// <returns></returns>
|
2022-11-18 11:30:09 +00:00
|
|
|
Task<AuthorizationCodeRefreshResponse> RequestToken(AuthorizationCodeRefreshRequest request, CancellationToken cancel = default);
|
2020-05-30 22:20:42 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Reequest an initial token via Authorization Code Auth
|
|
|
|
/// </summary>
|
2020-06-02 22:55:50 +01:00
|
|
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
2022-11-18 11:30:09 +00:00
|
|
|
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
|
2020-05-30 22:20:42 +01:00
|
|
|
/// <remarks>
|
|
|
|
/// https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow
|
|
|
|
/// </remarks>
|
|
|
|
/// <returns></returns>
|
2022-11-18 11:30:09 +00:00
|
|
|
Task<AuthorizationCodeTokenResponse> RequestToken(AuthorizationCodeTokenRequest request, CancellationToken cancel = default);
|
2020-06-02 22:55:50 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Swaps out a received code with a access token using a remote server
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
2022-11-18 11:30:09 +00:00
|
|
|
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
|
2020-06-02 22:55:50 +01:00
|
|
|
/// <remarks>
|
|
|
|
/// https://developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/
|
|
|
|
/// </remarks>
|
|
|
|
/// <returns></returns>
|
2022-11-18 11:30:09 +00:00
|
|
|
Task<AuthorizationCodeTokenResponse> RequestToken(TokenSwapTokenRequest request, CancellationToken cancel = default);
|
2020-06-02 22:55:50 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets a refreshed access token using an already received refresh token using a remote server
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request"></param>
|
2022-11-18 11:30:09 +00:00
|
|
|
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
|
2020-06-02 22:55:50 +01:00
|
|
|
/// <remarks>
|
|
|
|
/// https://developer.spotify.com/documentation/ios/guides/token-swap-and-refresh/
|
|
|
|
/// </remarks>
|
|
|
|
/// <returns></returns>
|
2022-11-18 11:30:09 +00:00
|
|
|
Task<AuthorizationCodeRefreshResponse> RequestToken(TokenSwapRefreshRequest request, CancellationToken cancel = default);
|
2020-05-13 22:49:54 +01:00
|
|
|
}
|
|
|
|
}
|