Reputation: 13
I want to get the User's profile that shared a Calendar with me but this call needs the id
or userPrincipalName
:
GET /users/{id | userPrincipalName}
The shared calendar only returns:
{
"id": "**********************************************=",
"name": "Lala Lalala",
"color": "auto",
"changeKey": "Epg+nQ9k3kuTN16cfoLtwAAAsZgDvA==",
"canShare": false,
"canViewPrivateItems": false,
"canEdit": true,
"owner": {
"name": "Lala Lalala",
"address": "[email protected]"
}
}
So how can I get the id
or userPrincipalName
of the shared calendar's owner?
Upvotes: 1
Views: 480
Reputation: 33094
For Work/School Accounts (Azure AD tenants), the userPrincipalName
is the owner's address (i.e. [email protected]
):
"owner": {
"name": "Lala Lalala",
"address": "[email protected]"
}
Assuming they're in the same tenant as your, you can retrieve their profile using GET https://graph.microsoft.com/v1.0/users/{owner.address}
.
Important: This does not, however, apply to Personal Accounts (MSA/Outlook.com). I only mention this because your example used [email protected]
as the address
.
Since Outlook.com is effectively a "single user" tenant, the only user you can retrieve is yourself (/me
). Just as you cannot access a user's data from another company's AAD, you cannot retrieve another Outlook.com user's profile. If you consider the pricacey implications of my access your personal contact information, it makes sense why this rule is in place.
Upvotes: 2
Reputation: 1874
No directly way to implement what you want. But you can get the id or userPrincipalName by two steps:
Get calendars whose owner is not you, the response like you have posted(official docs):
Use the address in the owner to call the following API:
The response with id and userPrincipalName:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", "id": "5eec0ff7-b007-48c4-87ae-7cddb085f234", "businessPhones": [], "displayName": "...", "givenName": "...", "jobTitle": null, "mail": "[email protected]", "mobilePhone": "8612345678", "officeLocation": "No WorkSpace", "preferredLanguage": null, "surname": "s", "userPrincipalName": "[email protected]" }
Upvotes: -1