File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
shell/agents/Microsoft.Azure.Agent Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -390,11 +390,20 @@ internal async Task CreateOrRenewTokenAsync(CancellationToken cancellationToken)
390390 . GetTokenAsync ( _tokenContext , cancellationToken ) ;
391391 }
392392 }
393- catch ( Exception e ) when ( e is not OperationCanceledException )
393+ catch ( Exception azureCliLoginException ) when ( azureCliLoginException is not OperationCanceledException )
394394 {
395- string message = $ "Failed to generate the user access token: { e . Message } .";
396- Telemetry . Trace ( AzTrace . Exception ( message ) , e ) ;
397- throw new TokenRequestException ( message , e ) ;
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+ }
398407 }
399408 }
400409
You can’t perform that action at this time.
0 commit comments