Code Sample - retrieve my files using Office 365 APIs

In synchronization with release of new Office 365 REST APIs, Microsoft has published lot of code samples and starter projects on their GitHub Page. One of those samples is Single Tenant MVC Web App which initially contains one example that shows how to retrieve contacts for current user (code in ContactsController.cs). Compared to other samples in OfficeDev GitHub, this one has much simpler project structure, and in essence it contains entire retrieval logic on one code file. Its primary purpose is to show programming approach against the APIs in simple and easy way, without spreading logic to much code files.

Following that idea, I forked the project and added functionality to retrieve users files. My fork contains additional controller (FilesController.cs), model and appropriate view. In the "Index" method, i perform Capability Discovery for "MyFiles" capability, create SharePointClient object and retrieve collection of Files for current user. Files collection contains all files saved in OneDrive for Business.

Full code of the controller is here.

Fork of the project is available on GitHub. In near future, I plan to implement full CRUD functionality against MyFiles API, using same approach - to demonstrate the API functionality.