We want to find the directory details in which user is a member. In Portal, these are found in Directories + Subscriptions
tab.
How to get the same details using Azure API?
We found this API but getting only one organisation
GET https://graph.microsoft.com/v1.0/organization
Is there a way for all organization's details in one API call? Thanks, Damodhar
Note that, you cannot get all the organizations details using Microsoft Graph API. Alternatively, you can use Azure Management API to fetch all the organizations associated to your account.
I registered one Azure AD application and granted below API permission in it:
Now, I generated access token using username password flow via Postman with below parameters:
POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token
grant_type:password
client_id: appId
client_secret: secret
scope: https://management.azure.com/.default
username: admin@xxxx.onmicrosoft.com
password: xxxxxxxxx
Response:
When I ran below Azure Management API call with generated token, I got list of organizations successfully as below:
GET https://management.azure.com/tenants?api-version=2022-12-01
Response:
Reference: Tenants - List - REST API (Azure Resource Management) | Microsoft