mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 14:46:26 +00:00
Also update authenticator if new refresh token was returned
This commit is contained in:
parent
eb97a0af97
commit
a340eaf43c
@ -17,6 +17,9 @@ dotnet_diagnostic.CA1308.severity = none
|
|||||||
dotnet_diagnostic.CA1002.severity = none
|
dotnet_diagnostic.CA1002.severity = none
|
||||||
# TODO: Enable for next major version, EventArgs breaking change:
|
# TODO: Enable for next major version, EventArgs breaking change:
|
||||||
dotnet_diagnostic.CA1003.severity = none
|
dotnet_diagnostic.CA1003.severity = none
|
||||||
|
|
||||||
|
dotnet_diagnostic.IDE0130.severity = none
|
||||||
|
|
||||||
#
|
#
|
||||||
# Sort using and Import directives with System.* appearing first
|
# Sort using and Import directives with System.* appearing first
|
||||||
dotnet_sort_system_directives_first = true
|
dotnet_sort_system_directives_first = true
|
||||||
|
@ -53,14 +53,18 @@ namespace SpotifyAPI.Web
|
|||||||
|
|
||||||
if (InitialToken.IsExpired)
|
if (InitialToken.IsExpired)
|
||||||
{
|
{
|
||||||
var tokenRequest = new AuthorizationCodeRefreshRequest(ClientId, ClientSecret, InitialToken.RefreshToken);
|
AuthorizationCodeRefreshRequest? tokenRequest = new(ClientId, ClientSecret, InitialToken.RefreshToken);
|
||||||
var refreshedToken = await OAuthClient.RequestToken(tokenRequest, apiConnector).ConfigureAwait(false);
|
AuthorizationCodeRefreshResponse? refreshedToken = await OAuthClient.RequestToken(tokenRequest, apiConnector).ConfigureAwait(false);
|
||||||
|
|
||||||
InitialToken.AccessToken = refreshedToken.AccessToken;
|
InitialToken.AccessToken = refreshedToken.AccessToken;
|
||||||
InitialToken.CreatedAt = refreshedToken.CreatedAt;
|
InitialToken.CreatedAt = refreshedToken.CreatedAt;
|
||||||
InitialToken.ExpiresIn = refreshedToken.ExpiresIn;
|
InitialToken.ExpiresIn = refreshedToken.ExpiresIn;
|
||||||
InitialToken.Scope = refreshedToken.Scope;
|
InitialToken.Scope = refreshedToken.Scope;
|
||||||
InitialToken.TokenType = refreshedToken.TokenType;
|
InitialToken.TokenType = refreshedToken.TokenType;
|
||||||
|
if (refreshedToken.RefreshToken != null)
|
||||||
|
{
|
||||||
|
InitialToken.RefreshToken = refreshedToken.RefreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
TokenRefreshed?.Invoke(this, InitialToken);
|
TokenRefreshed?.Invoke(this, InitialToken);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user