File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -321,7 +321,8 @@ public Mono<AccessToken> authenticateWithAzureCli(TokenRequestContext request) {
321321
322322 try {
323323 String tenant = IdentityUtil .resolveTenantId (tenantId , request , options );
324- if (!CoreUtils .isNullOrEmpty (tenant )) {
324+ // The default is not correct for many cases, such as when the logged in entity is a service principal.
325+ if (!CoreUtils .isNullOrEmpty (tenant ) && !tenant .equals (IdentityUtil .DEFAULT_TENANT )) {
325326 azCommand .append (" --tenant " ).append (tenant );
326327 }
327328 } catch (ClientAuthenticationException e ) {
@@ -362,7 +363,7 @@ public Mono<AccessToken> authenticateWithAzureDeveloperCli(TokenRequestContext r
362363
363364 try {
364365 String tenant = IdentityUtil .resolveTenantId (tenantId , request , options );
365- if (!CoreUtils .isNullOrEmpty (tenant )) {
366+ if (!CoreUtils .isNullOrEmpty (tenant ) && ! tenant . equals ( IdentityUtil . DEFAULT_TENANT ) ) {
366367 azdCommand .append (" --tenant-id " ).append (tenant );
367368 }
368369 } catch (ClientAuthenticationException e ) {
You can’t perform that action at this time.
0 commit comments