public void Token_expiration_should_be_correct() { // Arrange var sut = new PKCETokenResponse(); sut.CreatedAt = DateTime.UtcNow.AddDays(-14); sut.ExpiresIn = 1; // Act var result = sut.HasExpired(); // Assert result.Should().BeTrue(); }
public async Task <ISpotifyClient> CreateSpotifyClientAsync() { PKCETokenResponse tokenResponse = _config.Tokens; if (String.IsNullOrEmpty(tokenResponse.AccessToken) || String.IsNullOrEmpty(tokenResponse.RefreshToken)) { tokenResponse = await UseNewTokens(); } else if (tokenResponse.HasExpired()) { tokenResponse = await RefreshTokens(); } var config = SpotifyClientConfig.CreateDefault().WithAuthenticator(new PKCEAuthenticator(_config.ClientId, tokenResponse)); return(new SpotifyClient(config)); }