问题
I am trying to get an office 365 calendar, not for "me", but of a contact. i.e. in the company I work for (which has a global address list), I want to access Dave's calendar, as I would in outlook.
I have been through the documentation here, StackOverflow (e.g. here and here), plus Office 365 samples and Graph API samples (I believe Graph API is required for global address lists), but cannot find a way to do it.
I have 3 questions:
- Is this possible?
- If so, how please?
- If it's not possible with a global address list, is it possible with contacts created via Office 365 - and if so, how?
Any help much appreciated.
回答1:
It isn't currently possible if I understand your scenario correctly. If you are signing in as you, you only get access to your mailbox. You don't get access to other people, even if they've delegated access to you. This is something we're looking to improve upon, but for now you cannot do it.
You can create an app that uses the client credential auth flow, and an admin can grant access to all users, but I don't think that's the scenario you're going for.
回答2:
To start, yes this is possible, but you will need to use an App-Only token to access the Exchange APIs to get this data. It is important to remember that your access token for the API dictates what permissions you have to access that API. Assuming you are not an Admin, if you get a User token and try to query someone else's calander, you will get a "403 - Forbidden" since you only have the permissions to read your own calendar.
On the other hand, you can request for your application to have Application Permissions (versus Delegated Permssions) which will give you high level access to query the Exchange API without the context of a signed-in user. You can see documentation on these permissions here at Table 4.
Note that for any application that requests these level of permissions, it will require admin consent before the app will be able to get access. From the same page as above:
Note The tables describing service app permissions do not include a Requires admin consent column, as permissions for service apps always require admin consent. For more information about service apps, see Building service and daemon apps in Office 365.
Please check out the link in that quote, as it may really help you get started with developing a service application.
I hope that this helps!
来源:https://stackoverflow.com/questions/31572731/office-365-api-or-azure-ad-graph-api-get-someone-elses-calendar