AADSTS90002: Tenant 'xx' not found. This may happen if there are no active subscriptions for the tenant
Solution 1
Using ADAL to get access token using client credential flow :
AuthenticationContext authenticationContext =
new AuthenticationContext("https://login.microsoftonline.com/<tenantId>");
ClientCredential clientCredential = new ClientCredential(clientId, appKey);
AuthenticationResult result =
await authenticationContext.AcquireTokenAsync("https://resourceUrl",
clientCredential);
Reference : https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki/Client-credential-flows
And document : Service to service calls using client credentials
Solution 2
For me the issue was resolved by using older version of Microsoft.IdentityModel.Clients.ActiveDirectory. I had to used 3.13.8 version. Latest version has issues.
superninja
Updated on June 15, 2022Comments
-
superninja almost 2 years
I followed this tutorial to generate an access token from client app for target app. According to the comment for this tutorial, for the
resources
, I changed to App ID URL. But I am still not able to successfully generate bearer token for the target app.It shows this error message:
AdalException: {"error":"invalid_request","error_description":"AADSTS90002: Tenant '' not found. This may happen if there are no active subscriptions for the tenant....}
Anyone knows what else I missed?
-
Nan Yu about 5 yearsDo you set the correct tenant id or name ? To find your tenant id , click Azure Active Directory -->Properties-->Directory ID
-
Nan Yu about 5 years@WWpana Also try this : string Instance = "login.microsoftonline.com{0}"; string authority = string.Format(CultureInfo.InvariantCulture, Instance, "xxxx.onmicrosoft.com"); AuthenticationContext authenticationContext = new AuthenticationContext(authority);
-
superninja about 5 yearsI got it working! I entered the wrong tenant id :( thanks for your help!
-
mahan07 over 3 yearsYou are a saviour!!
-
Daniel de Zwaan over 3 yearsStill the case in November 2020!
-
Dan about 3 yearsThis fix is still applicable in March 2021