'Office365: Load email from an external account without the need to refresh

We would like to create an integration with our customer's Office 365 email account (not our account) so we can load emails coming from a certain sender and display them in our site. One solutions is basically to ask the customer for their username and password and then just login using EWS but this is horribly insecure and basic auth is about to be deprecated in EWS.

The other solution is using oAuth2 and OIDC however the access and refresh token will expire and we will constantly have to ask the user to re-sync with an admin account.

Is there a way to sync mail for a user without requiring them to re-sync when their token expires without using basic authentication?

I was thinking there might be a graph api subscription however I didn't see how to do this on external accounts and seems that it also need to be refreshed. The other solution might be an Office 365 plugin but I haven't found any tutorial on how to do this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source