This is a demonstration of Office 365 Patterns and Practices code, which shows how to create typical information management policy processes with app model. You can use this similar approach for any governance type business requirement, where you'd need to process sites, documents or other elements based on metadata.
- Using app only token
- Access SharePoint sites as a remote timer job
- Access sites and documents for policy checkingAccess sites and documents to
Actual code and additional details can be found from following address - https://github.com/OfficeDev/PnP/tree/master/Solutions/Governance.ContentTypeEnforceRetention