I have a SharePoint (2010) on-premises, plugged to an ADFS server. I deploy custom components (Web parts, _layouts pages) with custom code onto it.
One of these components must access data stored in an Exchange Online (Office 365) for the current user, like last emails and calendar events.
I'm trying to get this done from the server-side code hosted in my SharePoint.
SharePoint and Office 365 are both connected to the same on-prem ADFS.
The following diagram shows the situation:
I cannot find any information on how to code the access delegation to the Exchange Online.
Is there any code sample, tutorial or at least some hints on how to get access to the Exchange data on-behalf of the current user in this situation?
i.e. delegating credentials from SharePoint on-prem (ADFS) to Exchange Online API (same ADFS)?
As the user has already logged on the on-prem SharePoint (via ADFS), I don't want her/him to logon again or to give consent for a third-party app (thus excluding Graph API?).
- How can I get the correct "token" from ADFS while running server-side code on the SharePoint side, and then use it to get a token from Office 365?
- What API can I use to get the correct Office 365 "token" to authenticate the Exchange API request?
- What Exchange API can I use? EWS ? REST?
Notes:
- after running some tests, I'm quite confident we can replace "SharePoint" by "any ASP.NET app" in my question.
- if there's at least a "simple" solution all client-side, I could settle for it.