AADSTS90002: Tenant 'xx' not found. This may happen if there are no active subscriptions for the tenant

17,029

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.

Share:
17,029
superninja
Author by

superninja

Updated on June 15, 2022

Comments

  • superninja
    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
    Nan Yu about 5 years
    Do you set the correct tenant id or name ? To find your tenant id , click Azure Active Directory -->Properties-->Directory ID
  • Nan Yu
    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
    superninja about 5 years
    I got it working! I entered the wrong tenant id :( thanks for your help!
  • mahan07
    mahan07 over 3 years
    You are a saviour!!
  • Daniel de Zwaan
    Daniel de Zwaan over 3 years
    Still the case in November 2020!
  • Dan
    Dan about 3 years
    This fix is still applicable in March 2021