mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 14:46:26 +00:00
Add interfaces for tokens (#499)
* Add interfaces for tokens * Delete UpgradeLog.htm * Changed Namespace Co-authored-by: Jonas Dellinger <jonas@dellinger.dev>
This commit is contained in:
parent
d20e83f4f5
commit
a9c4aba7fa
@ -11,6 +11,10 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
private readonly IAPIConnector _apiConnector;
|
||||
|
||||
public SpotifyClient(IToken token) :
|
||||
this(SpotifyClientConfig.CreateDefault(token?.AccessToken ?? throw new ArgumentNullException(nameof(token)), token.TokenType))
|
||||
{ }
|
||||
|
||||
public SpotifyClient(string token, string tokenType = "Bearer") :
|
||||
this(SpotifyClientConfig.CreateDefault(token, tokenType))
|
||||
{ }
|
||||
|
@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class AuthorizationCodeRefreshResponse
|
||||
public class AuthorizationCodeRefreshResponse: IUserToken
|
||||
{
|
||||
public string AccessToken { get; set; } = default!;
|
||||
public string TokenType { get; set; } = default!;
|
||||
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class AuthorizationCodeTokenResponse
|
||||
public class AuthorizationCodeTokenResponse: IRefreshableToken
|
||||
{
|
||||
public string AccessToken { get; set; } = default!;
|
||||
public string TokenType { get; set; } = default!;
|
||||
|
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class ClientCredentialsTokenResponse
|
||||
public class ClientCredentialsTokenResponse: IToken
|
||||
{
|
||||
public string AccessToken { get; set; } = default!;
|
||||
public string TokenType { get; set; } = default!;
|
||||
|
@ -0,0 +1,13 @@
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// An user token, which can be refreshed
|
||||
/// </summary>
|
||||
public interface IRefreshableToken : IUserToken
|
||||
{
|
||||
/// <summary>
|
||||
/// Refresh token
|
||||
/// </summary>
|
||||
public string RefreshToken { get; set; }
|
||||
}
|
||||
}
|
30
SpotifyAPI.Web/Models/Response/Interfaces/IToken.cs
Normal file
30
SpotifyAPI.Web/Models/Response/Interfaces/IToken.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// A token to access the Spotify API
|
||||
/// </summary>
|
||||
public interface IToken
|
||||
{
|
||||
/// <summary>
|
||||
/// Access token string
|
||||
/// </summary>
|
||||
public string AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Type of this token (eg. Bearer)
|
||||
/// </summary>
|
||||
public string TokenType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Auto-Initalized to UTC Now
|
||||
/// </summary>
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the token still valid?
|
||||
/// </summary>
|
||||
public bool IsExpired { get; }
|
||||
}
|
||||
}
|
13
SpotifyAPI.Web/Models/Response/Interfaces/IUserToken.cs
Normal file
13
SpotifyAPI.Web/Models/Response/Interfaces/IUserToken.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// A token which allows you to access the API as user
|
||||
/// </summary>
|
||||
public interface IUserToken : IToken
|
||||
{
|
||||
/// <summary>
|
||||
/// Comma-Seperated list of scopes
|
||||
/// </summary>
|
||||
public string Scope { get; set; }
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace SpotifyAPI.Web
|
||||
{
|
||||
public class PKCETokenResponse
|
||||
public class PKCETokenResponse: IRefreshableToken
|
||||
{
|
||||
public string AccessToken { get; set; } = default!;
|
||||
public string TokenType { get; set; } = default!;
|
||||
|
Loading…
Reference in New Issue
Block a user