Reputation: 18720
In my application, the user signs in using their Office365 credentials and then
I want to import the data of the users (id
, mail
, displayName
) in the same
organization into my database.
When another person from the same organization logs in into my app, that other person should see the same list of users as the first one.
I tried several queries in the Graph Explorer, but none of them has a response, which would allow to determine that two people belong to the same organization.
"My profile" (/v1.0/me/
) response contains a lot
of data, but no tenant ID (or something similar):
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"id": "16f5a7b6-5a15-4568-aa5a-31bb117e9967",
"businessPhones": [],
"displayName": "Anne Weiler",
"givenName": "Anne",
"jobTitle": "Manufacturing Lead",
"mail": "[email protected]",
"mobilePhone": "+1 3528700812",
"officeLocation": null,
"preferredLanguage": "en-US",
"surname": "Weiler",
"userPrincipalName": "[email protected]"
}
Same applies to the "all users in the organization" (/v1.0/users
) response.
How can I extract the information from Microsoft Graph that would allow me to detect that two different users work in the same organization?
Upvotes: 1
Views: 61
Reputation: 33114
You could use the id
returned by the /organiozation endpoint:
https://graph.microsoft.com/v1.0/organization?$select=id,displayName
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#organization(id,displayName)",
"value": [
{
"id": "c07ab59f-ce09-49f8-b4c4-9c6dd4f0d8bb",
"displayName": "Microsoft API Sandbox"
}
]
}
Upvotes: 1