@@ -151,7 +151,7 @@ internal void ResetCachedToken(string? claimsChallenge = null)
151151 }
152152
153153 private async Task < AccessToken > GetNewTokenAsync (
154- ITrace trace )
154+ ITrace trace )
155155 {
156156 // Use a local variable to avoid the possibility the task gets changed
157157 // between the null check and the await operation.
@@ -279,6 +279,7 @@ private async ValueTask<AccessToken> RefreshCachedTokenWithRetryHelperAsync(
279279 {
280280 DefaultTrace . TraceInformation (
281281 "Stop RefreshTokenWithIndefiniteRetries because cancellation is requested" ) ;
282+
282283 break ;
283284 }
284285
@@ -322,9 +323,7 @@ private async ValueTask<AccessToken> RefreshCachedTokenWithRetryHelperAsync(
322323
323324 if ( this . cachedAccessToken . Value . ExpiresOn < DateTimeOffset . UtcNow )
324325 {
325- throw new ArgumentOutOfRangeException (
326- $ "TokenCredential.GetTokenAsync returned a token that is already expired. " +
327- $ "Current Time:{ DateTime . UtcNow : O} ; Token expire time:{ this . cachedAccessToken . Value . ExpiresOn : O} ") ;
326+ throw new ArgumentOutOfRangeException ( $ "TokenCredential.GetTokenAsync returned a token that is already expired. Current Time:{ DateTime . UtcNow : O} ; Token expire time:{ this . cachedAccessToken . Value . ExpiresOn : O} ") ;
328327 }
329328
330329 // Clear claims challenge after successful token acquisition
@@ -374,7 +373,6 @@ private async ValueTask<AccessToken> RefreshCachedTokenWithRetryHelperAsync(
374373 $ "hasClaimsChallenge = { this . cachedClaimsChallenge != null } , " +
375374 $ "retry = { retry } , " +
376375 $ "Exception = { lastException . Message } ") ;
377-
378376 // Don't retry on auth failures
379377 if ( exception is RequestFailedException requestFailedException &&
380378 ( requestFailedException . Status == ( int ) HttpStatusCode . Unauthorized ||
@@ -384,7 +382,6 @@ private async ValueTask<AccessToken> RefreshCachedTokenWithRetryHelperAsync(
384382 this . cachedClaimsChallenge = null ;
385383 throw ;
386384 }
387-
388385 bool didFallback = this . scopeProvider . TryFallback ( exception ) ;
389386
390387 if ( didFallback )
@@ -399,9 +396,7 @@ private async ValueTask<AccessToken> RefreshCachedTokenWithRetryHelperAsync(
399396 {
400397 throw new ArgumentException ( "Last exception is null." ) ;
401398 }
402-
403399 this . cachedClaimsChallenge = null ;
404-
405400 // The retries have been exhausted. Throw the last exception.
406401 throw lastException ;
407402 }
0 commit comments