Skip to content

Commit a340eaf

Browse files
committed
Also update authenticator if new refresh token was returned
1 parent eb97a0a commit a340eaf

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ dotnet_diagnostic.CA1308.severity = none
1717
dotnet_diagnostic.CA1002.severity = none
1818
# TODO: Enable for next major version, EventArgs breaking change:
1919
dotnet_diagnostic.CA1003.severity = none
20+
21+
dotnet_diagnostic.IDE0130.severity = none
22+
2023
#
2124
# Sort using and Import directives with System.* appearing first
2225
dotnet_sort_system_directives_first = true

SpotifyAPI.Web/Authenticators/AuthorizationCodeAuthenticator.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ public async Task Apply(IRequest request, IAPIConnector apiConnector)
5353

5454
if (InitialToken.IsExpired)
5555
{
56-
var tokenRequest = new AuthorizationCodeRefreshRequest(ClientId, ClientSecret, InitialToken.RefreshToken);
57-
var refreshedToken = await OAuthClient.RequestToken(tokenRequest, apiConnector).ConfigureAwait(false);
56+
AuthorizationCodeRefreshRequest? tokenRequest = new(ClientId, ClientSecret, InitialToken.RefreshToken);
57+
AuthorizationCodeRefreshResponse? refreshedToken = await OAuthClient.RequestToken(tokenRequest, apiConnector).ConfigureAwait(false);
5858

5959
InitialToken.AccessToken = refreshedToken.AccessToken;
6060
InitialToken.CreatedAt = refreshedToken.CreatedAt;
6161
InitialToken.ExpiresIn = refreshedToken.ExpiresIn;
6262
InitialToken.Scope = refreshedToken.Scope;
6363
InitialToken.TokenType = refreshedToken.TokenType;
64+
if (refreshedToken.RefreshToken != null)
65+
{
66+
InitialToken.RefreshToken = refreshedToken.RefreshToken;
67+
}
6468

6569
TokenRefreshed?.Invoke(this, InitialToken);
6670
}

0 commit comments

Comments
 (0)