I am implementing Microsoft.Identity Login in my web app to allow any organization users (outside my Tenant Id) to login. The configuration in my appsettings.json is as below.
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "domain.com",
"ClientId": "GUID_CLIENT_ID_FROM_ENTRA",
"TenantId": "organizations",
"CallbackPath": "/signin-oidc",
"ClientSecret": "CLIENT_SECRET",
"SkipUnrecognizedRequests": true
}
The code used to retrieve Access Token is as below :
RestClient _client = new RestClient("https://login.microsoftonline.com");
var request = new RestRequest("/" + _configuration["AzureAd:TenantId"] + "/oauth2/token", Method.Post);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("grant_type", "client_credentials");
request.AddParameter("client_secret", _configuration["AzureAd:ClientSecret"]);
request.AddParameter("client_id", _configuration["AzureAd:ClientId"]);
request.AddParameter("resource", "20e940b3-4c77-4b0b-9a53-9e16a1b010a7");
var response = await _client.ExecuteAsync(request);
When I am using the TenantId of the organization where the “App” has been registered on Entra Admin portal, the above code works but as soon as I change the TenantId to “organizations”, it fails with the below error –
AADSTS50059: No tenant-identifying information found in either the
request or implied by any provided credentials
I have configured my App to allow ” Change the setting to Accounts in any organizational directory” as mentioned here
Please advise on a solution.