private static async Task UpdateSpotifyUserAccessToken(User user, SpotifyService spotifyService, ApplicationDbContext context) { var token = await spotifyService.GetAccessToken(user.SpotifyRefreshToken, SpotifyGrantType.RefreshToken); if (string.IsNullOrWhiteSpace(token.Error)) { user.SpotifyAccessToken = token.AccessToken; user.SpotifyRefreshToken = token.RefreshToken; } else { // Invalid tokens, we remove from database context.Users.Remove(user); } await context.SaveChangesAsync(); }