Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Deep Dive into Office 365 APIs for SharePoint Site services

7,960 views

Published on

Office 365 is constantly evolving and Microsoft is consolidating product specific API sets to one Office 365 API. One of the major products in Office 365 is SharePoint Online which has the Client Side Object Model (CSOM) for remote access into SharePoint. With two API sets targeting the same platform guidance is required. This session covers a short overview, but quickly takes a deep dive into the Office 365 API for SharePoint Site services. Topics covered are authentication, discovery, CSOM and REST. Demos supporting the topics show examples of file and list operations. By combining both API sets you get the best of both worlds and opens up new possibilities. Joining this session enables you as a developer or architect to choose the best solution approach to your customer requirements.

Published in: Software

Deep Dive into Office 365 APIs for SharePoint Site services

  1. 1. DEEP DIVE INTO OFFICE 365 APIS FOR SHAREPOINT SITE SERVICES Bram de Jager Technology Consultant | Macaw Workplace Solutions Microsoft Certified Solutions Master: SharePoint @bramdejager | bramdejager.wordpress.com
  2. 2. AGENDA • Overview • Get Started with Office 365 APIs • File Operations with SharePointClient • List Operations with REST • Wrap-up
  3. 3. OVERVIEW Deep Dive into Office 365 APIs for SharePoint Site services
  4. 4. API’S EVERYWHERE! • SharePoint APIs o .NET SSOM o .NET CSOM o JavaScript JSOM o REST/OData endpoints • Office 365 API o Connect to your users' mail, calendars, contacts, and files into your app • Microsoft Graph (previously known as Office 365 Unified API) o Single endpoint for connecting to all of the Office 365 services
  5. 5. OFFICE 365API SharePointExchange & Outlook.com OneDriveActive Directory Search Sites, Lists and Libs Taxonomy BCSWorkflow …
  6. 6. MICROSOFT GRAPH https://graph.microsoft.com/
  7. 7. WHY DO I NEED THE OFFICE 365APIS? • Access Office 365 data outside of the Office 365 context o But also integrate with the Office 365 and App Launcher • Single set of APIs for (almost) all Office 365 services • Uniform authentication, with support for o Federation support (AD FS) o Multi-Factor Authentication (MFA)
  8. 8. GET STARTED WITH OFFICE 365APIS Deep Dive into Office 365 APIs for SharePoint Site services
  9. 9. DISCOVERY SERVICE • Returns a collection of endpoints specific to current user • Intended as the starting point for application o 1. Sign-In o 2. Get authorized o 3. Discover endpoints for resource o 4. Get Token o 5. Access resource • API Libraries simplify necessary code • Capabilities: https://api.office.com/discovery/v1.0/me/allServices
  10. 10. AUTHENTICATION FLOW Native Application Azure AD Authorization Endpoint Azure AD Token Endpoint Office 365 API Request authorization code Return authorization code Sign-in via browser (pop-up) Redeem authorization code and acquire access token for Office 365 resource Return access token and refresh token Call Office 365 API using the access token Return Http Response
  11. 11. ADAL • Azure AD Authentication Library (ADAL) supports: o Token Acquisition o Token Cache storing access tokens and refresh tokens o Automatic Token Refresh o Asynchronous Methods
  12. 12. PERMISSIONS (CONNECTED SERVICE)
  13. 13. GRANTACCESS TO OFFICE 365
  14. 14. REVOKE CONSENT • Navigate to https://portal.office.com/myapps
  15. 15. APP LAUNCHER INTEGRATION
  16. 16. DEMO • Get started with Office 365 App development o Register Office 365 App in Visual Studio o Grant access (user consent) o Implement ADAL for .NET
  17. 17. FILE OPERATIONS WITH SHAREPOINTCLIENT Deep Dive into Office 365 APIs for SharePoint Site services
  18. 18. SHAREPOINT SITES SERVICES • Provides access to SharePoint Online REST API • SharePointClient class simplifies programming, but limited functionality • Direct REST API calls more complex, but exposes more functionality
  19. 19. SHAREPOINTCLIENT CLASS • Discovery Service discovers resource • SharePointClient.Files abstracts Files API https://api.office.com/discovery/v1.0/me/ https://api.office.com/discovery/ https://company.sharepoint.com/
  20. 20. GET FILES COLLECTION • Get folders and files collection and read file metadata • Get files in specific folder • Type property is either “File” or “Folder”
  21. 21. BUTTHERE ISACATCH! • The API searches for two document libraries, named o (1) Shared Documents o (2) Documents • If libraries do not exist, then… o {"error":{"code":"-2146232832, Microsoft.SharePoint.SPException","message":"The file |0 does not exist."}}
  22. 22. DOCUMENT LIBRARIES DO NOT EXIST
  23. 23. DEMO • Implement Get Files collection • Scenario for the supported document libraries used by the Office 365 API for Sites o Site contains 3 document libraries, named: Shared Documents, Documents, Other Documents o Remove Shared Documents library o Remove Documents library
  24. 24. ADD NEW FILE • Use AddAsync() method • Provide a file name and the file stream
  25. 25. DELETINGAFILE • Get the file using GetById() method • Delete using DeleteAsync() method
  26. 26. LIST OPERATIONS WITH REST Deep Dive into Office 365 APIs for SharePoint Site services
  27. 27. READING LIST ITEMS • Office 365 APIs do not support list operations • Access the SharePoint REST API with the Access Token from the Office 365 API
  28. 28. GETACCESS TOKEN
  29. 29. DEMO • Implement Reading List Items collection • Use Office 365 API to retrieve Access Token
  30. 30. OTHER REST OPERATIONS • List Items o Adding a list item o Updating a list item o Deleting a list item • Other REST APIs o Taxonomy o Search (Office Graph) o BCS o Workflow o …
  31. 31. WRAP-UP Deep Dive into Office 365 APIs for SharePoint Site services
  32. 32. KEY TAKEAWAY • One API for accessing all Office 365 data o API makes it easier, limited functionality o Reuse the Access Token for REST calls • Single repeatable pattern for o Mail o Contact o Calendar o Files o OneDrive o …
  33. 33. KEY TAKEAWAY • Another approach to providing solutions o Build a solution which connects to all Office 365 service o App Launcher integration o Use all capabilities provided by ASP.NET web application o Integrate these Office 365 services into o SharePoint Add-ins o Office Add-ins o Native apps: Windows Universal Apps, iOS, Android
  34. 34. RESOURCES • Office Dev Center, http://dev.office.com • Get started with Office 365 APIs, http://dev.office.com/getting-started/office365apis • Office 365 API reference, https://msdn.microsoft.com/en- us/office/office365/api/api-catalog • Files REST API reference, https://msdn.microsoft.com/office/office365/APi/files- rest-operations • Authorization Code Grant Flow, https://msdn.microsoft.com/en- us/library/azure/dn645542.aspx • Kirk Evans Fiddler add-in (oAuth inspector), http://blogs.msdn.com/b/kaevans/archive/2015/03/30/updated-fiddler-oauth- inspector.aspx
  35. 35. SharePoint Client Browser • Audience: Developer and IT Pro • Insights into your Office 365 Tenant and/or Site Collection • Exposes the SharePoint CSOM • Supports SharePoint Online and SharePoint Server • Just released new version • Over 29.000 downloads already! • http://spcb.codeplex.com
  36. 36. QUESTIONS? Bram de Jager @bramdejager | bramdejager.wordpress.com

×