Can't list all tenants with REST API

Ana Cruz 21 Reputation points
2021-09-15T23:42:51.26+00:00

I'm trying to get a list of all my tenants using the resource management Tenants - List API call, but I'm not seeing a complete response.

Testing it in different ways, these are the results I get (I currently have 2 tenants):

  • When I use the "try it" button here, I see both of the tenants, as expected.
  • When I use postman, I see only one tenant and less properties.
  • When I use the sdk for Go, I see only one tenant and less properties (same as postman).

What can I do to get the same results as "try it"? Any help is appreciated!

Here is the "try it" result:
132489-image.png

The postman result (same as I get for the Go sdk):
132468-image.png

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,111 questions
0 comments No comments
{count} votes

Accepted answer
  1. AmanpreetSingh-MSFT 56,646 Reputation points
    2021-09-16T06:22:12.763+00:00

    Hi @Ana Cruz • Thank you for reaching out.

    I was able to reproduce it in my test tenant.

    • When I use the "try it" button here, I see both of the tenants, as expected.

    When you use the "try it" button the token is acquired in user's context and when that token is passed as bearer token with the REST call, the list of tenants is acquired under user context and the results include all the tenants, the user account has access to.

    • When I use postman, I see only one tenant and less properties.

    When you are using postman, you must be acquiring token under application/servicePrincipal context via Client_Credentials flow. When you pass app/sp token as bearer token, the information is fetched under application context and results include only the Home tenant, where the application is registered with limited information about the tenant due to application context. This is expected behavior.

    • When I use the sdk for Go, I see only one tenant and less properties (same as postman).

    Again, you must be using the Client_Credentials flow to acquire token.

    -------------------

    To test this out, you can acquire a token using below call via Postman, you will get the token under user context (use cloud-only user, not federated user account). You can then use this token as bearer to make the REST call.

    132577-image.png

    To acquire the token using above method, you must provide admin consent for below permission under API permissions blade of the application whose client ID you used in the above call.

    132633-image.png

    -----------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.