File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed
shell/agents/Microsoft.Azure.Agent Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -386,24 +386,16 @@ internal async Task CreateOrRenewTokenAsync(CancellationToken cancellationToken)
386386
387387 if ( needRefresh )
388388 {
389- _accessToken = await new AzureCliCredential ( )
389+ _accessToken = await new ChainedTokenCredential ( new AzureCliCredential ( ) ,
390+ new InteractiveBrowserCredential ( ) )
390391 . GetTokenAsync ( _tokenContext , cancellationToken ) ;
391392 }
392393 }
393- catch ( Exception azureCliLoginException ) when ( azureCliLoginException is not OperationCanceledException )
394+ catch ( Exception e ) when ( e is not OperationCanceledException )
394395 {
395- string message = $ "Failed to generate the user access token using az cli and try to fallback to interactive browser: { azureCliLoginException . Message } .";
396- Telemetry . Trace ( AzTrace . Exception ( message ) , azureCliLoginException ) ;
397- try {
398- _accessToken = await new InteractiveBrowserCredential ( )
399- . GetTokenAsync ( _tokenContext , cancellationToken ) ;
400- }
401- catch ( Exception interactiveBrowserLoginException ) when ( interactiveBrowserLoginException is not OperationCanceledException )
402- {
403- message = $ "Failed to generate the user access token using interactive browser: { interactiveBrowserLoginException . Message } .";
404- Telemetry . Trace ( AzTrace . Exception ( message ) , interactiveBrowserLoginException ) ;
405- throw new TokenRequestException ( message , interactiveBrowserLoginException ) ;
406- }
396+ string message = $ "Failed to generate the user access token: { e . Message } .";
397+ Telemetry . Trace ( AzTrace . Exception ( message ) , e ) ;
398+ throw new TokenRequestException ( message , e ) ;
407399 }
408400 }
409401
You can’t perform that action at this time.
0 commit comments