diff --git a/src/Microsoft.Identity.Web/TokenAcquisition.cs b/src/Microsoft.Identity.Web/TokenAcquisition.cs index a3987cd33..20da2b4ce 100644 --- a/src/Microsoft.Identity.Web/TokenAcquisition.cs +++ b/src/Microsoft.Identity.Web/TokenAcquisition.cs @@ -271,14 +271,14 @@ public async Task GetAccessTokenForAppAsync( throw new ArgumentException(IDWebErrorMessage.ClientCredentialScopeParameterShouldEndInDotDefault, nameof(scope)); } - if (!string.IsNullOrEmpty(tenant) && _metaTenantIdentifiers.Contains(tenant)) + if (string.IsNullOrEmpty(tenant)) { - throw new ArgumentException(IDWebErrorMessage.ClientCredentialTenantShouldBeTenanted, nameof(tenant)); + tenant = _applicationOptions.TenantId ?? _microsoftIdentityOptions.TenantId; } - if (!string.IsNullOrEmpty(_microsoftIdentityOptions.TenantId) && _metaTenantIdentifiers.Contains(_microsoftIdentityOptions.TenantId)) + if (!string.IsNullOrEmpty(tenant) && _metaTenantIdentifiers.Contains(tenant)) { - throw new ArgumentException(IDWebErrorMessage.ClientCredentialTenantShouldBeTenanted, nameof(_microsoftIdentityOptions.TenantId)); + throw new ArgumentException(IDWebErrorMessage.ClientCredentialTenantShouldBeTenanted, nameof(tenant)); } // Use MSAL to get the right token to call the API