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.

Extend your development skills set using MS Graph

223 views

Published on

Yannick Borghmans

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Extend your development skills set using MS Graph

  1. 1. SharePoint Saturday Belgium 2017 • October 21 • Brussels Track: Developer| Level: 200 Extend your development skills set using MS Graph Yannick Borghmans @yborghmans
  2. 2. PlatinumGoldSilver
  3. 3. SharePoint Saturday Belgium 2017 • October 21 • Brussels Agenda • What’s Microsoft Graph • Calling the API and getting entities • Authentication • How to get started with development • Graph explorer • Authentication • Coding • Roadmap • + Next session => Donald • .NET, Extensions, Webhooks, SP
  4. 4. SharePoint Saturday Belgium 2017 • October 21 • Brussels What’s Microsoft Graph?
  5. 5. SharePoint Saturday Belgium 2017 • October 21 • Brussels
  6. 6. SharePoint Saturday Belgium 2017 • October 21 • Brussels SITES GROUPS ME CONVERSATIONS CONTENT INSIGHTS CONTACTS PEOPLE ORGANIZATION TASKS EMAIL EVENTS DOCUMENTS DEVICES CHATS TEAMS ACTIVITY TRENDING SHARED REPORTS Microsoft Graph
  7. 7. SharePoint Saturday Belgium 2017 • October 21 • Brussels Users Groups Outlook OneNote more…SharePoint IntuneTeams Azure ADPlanner Excel https://graph.microsoft.com Your appOne endpoint One token All users Microsoft Graph API Access user, group and organizational data
  8. 8. SharePoint Saturday Belgium 2017 • October 21 • Brussels Calling the Microsoft Graph Microsoft Graph
  9. 9. SharePoint Saturday Belgium 2017 • October 21 • Brussels Calling the API & Entities
  10. 10. SharePoint Saturday Belgium 2017 • October 21 • Brussels Calling the API • HTTP verbs dictate the request intent: GET | POST | PATCH | PUT | DELETE • Version: /v1.0 or /beta • Resource: /users, /groups, /sites, /drives, /devices, more… • Member from collection: /users/AAA • Property: /users/AAA/department • Traverse to related resources via navigations: /users/AAA/events • Query parameters: /users/AAA/events?$top=5 o Format results: $select | $orderby o Control results: $filter | $expand o Paging: $top | $skip | $skiptoken /{version} ?{query-parameters}/{resource}/{id}/{property}
  11. 11. SharePoint Saturday Belgium 2017 • October 21 • Brussels Resources available (/v1.0) Users Messages MailFolder Events Contact (Folder) LicenseDetails Drives Driveitem Groups Conversations Tasks ...
  12. 12. SharePoint Saturday Belgium 2017 • October 21 • Brussels Resources available (/beta) Users Messages MailFolder Events Contact (Folder) LicenseDetails Drives Driveitem Groups Conversations Tasks Teams ChatThread ProjectRome Reports ...
  13. 13. SharePoint Saturday Belgium 2017 • October 21 • Brussels Users – common operations
  14. 14. SharePoint Saturday Belgium 2017 • October 21 • Brussels https://graph.microsoft.com/v1.0/me { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity", "id": "785452c3-e854-4f7b-b6f2-23ab357898a9", "businessPhones": [ "8006427676" ], "displayName": "MOD Administrator", "givenName": "MOD", "jobTitle": null, "mail": "admin@M365x135018.onmicrosoft.com", "mobilePhone": "425-882-1032", "officeLocation": null, "preferredLanguage": "en-US", "surname": "Administrator", "userPrincipalName": "admin@M365x135018.onmicrosoft.com" }
  15. 15. SharePoint Saturday Belgium 2017 • October 21 • Brussels https://graph.microsoft.com/v1.0/me?$select =displayName,skills { "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#users(displayName,ski lls)/$entity", "displayName": "MOD Administrator", "skills": [ "O365 development" ] }
  16. 16. SharePoint Saturday Belgium 2017 • October 21 • Brussels https://graph.microsoft.com/v1.0/me/drive/recent { "@odata.type": "#microsoft.graph.driveItem", "createdBy": { "user": { "email": "admin@M365x135018.onmicrosoft.com", "displayName": "MOD Administrator" } }, "createdDateTime": "2017-10-07T01:34:44Z", "id": "01AWEBQD3AXC2JGWHY65GLOG3XCR4YVGDO", "lastModifiedBy": { "user": { "email": "admin@M365x135018.onmicrosoft.com", "displayName": "MOD Administrator“ } }, "lastModifiedDateTime": "2017-06-01T17:37:48Z", "name": "High Density Print Head Installation Storyboard.pptx", "parentReference": { "driveId": "b!QWWNUVTcuUW0OLVrvm50FNtajrrVyPdJjNnOgpYlCUeh-XsODUNRSLlLssX3oKqp", "driveType": "business" }, "webUrl": "https://m365x135018.sharepoint.com/sites/VideoProduction/_... ", "size": 1007584 },
  17. 17. SharePoint Saturday Belgium 2017 • October 21 • Brussels Demo Graph Explorer
  18. 18. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365
  19. 19. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 - Delve
  20. 20. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 - Outlook
  21. 21. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 – Sharepoint.aspx
  22. 22. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 – OneDrive
  23. 23. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 - Groups
  24. 24. SharePoint Saturday Belgium 2017 • October 21 • Brussels Where is it included in O365 – People cards
  25. 25. SharePoint Saturday Belgium 2017 • October 21 • Brussels Authentication
  26. 26. SharePoint Saturday Belgium 2017 • October 21 • Brussels Multiple concepts Azure v1 endpoint vs Azure v2 endpoint 01 Registering Azure/AAD vs apps.dev.microsoft.com 02 Permissions 03 Admin consents 04 Authentication flows 05
  27. 27. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure v1 endpoint vs Azure v2 endpoint Work and school Personal with ADAL with ADAL
  28. 28. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure v1 endpoint vs Azure v2 endpoint Example: Web Application + Service API v1 => 2 AAD applications (Web Application + Native Application) v2 => 1 AAD Application, multiple platforms
  29. 29. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure v1 endpoint vs Azure v2 endpoint Available libraries for authentication: v1 => ADAL v2 => MSAL (preview) • Configurable token cache that stores access tokens and refresh tokens • Automatic token refresh when an access token expires and a refresh token is available • Support for asynchronous method calls • ...
  30. 30. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure v1 endpoint vs Azure v2 endpoint • Scopes instead of resources • Resource Identifier, or AppID URI: https://graph.windows.net/ • Scopes, or OAuth2Permissions: Directory.Read, Directory.Write, etc. GET https://login.microsoftonline.com/common/oauth2/v2.0/authorize? client_id=2d4d11a2-f814-46a7-890a-274a72a7309e &scope=https%3A%2F%2Fgraph.windows.net%2Fdirectory.read%20https%3A%2F%2Fgraph.windows.net%2Fdirectory.write GET https://login.microsoftonline.com/common/oauth2/authorize? client_id=2d4d11a2-f814-46a7-890a-274a72a7309e &resource=https%3A%2F%2Fgraph.windows.net%2F ...
  31. 31. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure v1 endpoint vs Azure v2 endpoint • Incremental and dynamic consent v1 => Permissions where set in AAD at app creation time Adding permissions over time was a difficult process v2 => Using scope attribute while application grows
  32. 32. SharePoint Saturday Belgium 2017 • October 21 • Brussels Permissions - examples • Calendars.Read • Calendars.Read.Shared • Calendars.ReadWrite • Calendars.ReadWrite.Shared • User.ReadBasic.All • User.Read • User.ReadWrite • User.Read.All • User.ReadWrite.All • Directory.Read.All • Directory.ReadWrite.All • Directory.AccessAsUser.All • ...
  33. 33. SharePoint Saturday Belgium 2017 • October 21 • Brussels Permissions • Delegated Permissions • Are used by apps that have a signed-in user present • Application Permissions • Are used by apps that run without a signed-in user present
  34. 34. SharePoint Saturday Belgium 2017 • October 21 • Brussels Effective Permissions – e.g. User.ReadWrite.All • Delegated Permissions • Least priviliged intersection of the delegated permissions • Application Permissions • full level of privileged implied by the permission
  35. 35. SharePoint Saturday Belgium 2017 • October 21 • Brussels Admin consent • Global administrator has to give it consent about the permissions
  36. 36. SharePoint Saturday Belgium 2017 • October 21 • Brussels Admin consent • If not given => • Error for end-user • Consent question for global administrator
  37. 37. SharePoint Saturday Belgium 2017 • October 21 • Brussels Implicit flow aka Client-Side Flow
  38. 38. SharePoint Saturday Belgium 2017 • October 21 • Brussels
  39. 39. SharePoint Saturday Belgium 2017 • October 21 • Brussels Implicit flow aka Client-Side Flow • Typically used by client side scripts (JS, TS, Angular, React ...) • No client-secret due to no secure place to store it • Temporary token
  40. 40. SharePoint Saturday Belgium 2017 • October 21 • Brussels Client credentials Flow aka Server-Side Flow
  41. 41. SharePoint Saturday Belgium 2017 • October 21 • Brussels
  42. 42. SharePoint Saturday Belgium 2017 • October 21 • Brussels Client credentials Flow aka Server-Side Flow • If your application can keep a (client) secret • Server-server communication, webjobs, services,... • Without interaction of an user • Application ID + ? • Client secrect • Certificate
  43. 43. SharePoint Saturday Belgium 2017 • October 21 • Brussels How to get started with development
  44. 44. SharePoint Saturday Belgium 2017 • October 21 • Brussels What can you do? • What next possible meeting time for a group? • Who is the manager of a specific person? • On what documents is my meeting partner working on?
  45. 45. SharePoint Saturday Belgium 2017 • October 21 • Brussels Azure configuration 1. Register a new application Azure AD 1. Configure properties 1. App ID URI 2. Reply URL 2. Add permissions (+ Grant permissions) 3. Enable implicit flow (client side..)
  46. 46. SharePoint Saturday Belgium 2017 • October 21 • Brussels Code configuration 1. Where to start from • Scratch • dev.microsoft.com/graph => code samples • Pnp Github => code samples 2. Libraries to use • SDK’s (.NET, JS, IOS, Android, PHP) • ADAL, MSAL
  47. 47. SharePoint Saturday Belgium 2017 • October 21 • Brussels
  48. 48. SharePoint Saturday Belgium 2017 • October 21 • Brussels Demo Registration of your app Github code samples Code example
  49. 49. SharePoint Saturday Belgium 2017 • October 21 • Brussels Roadmap
  50. 50. SharePoint Saturday Belgium 2017 • October 21 • Brussels Capabilities Announcements at Ignite Generally Available ( v1.0 ) Preview ( beta ) Delta query for OneDrive, AAD and Outlook Web hooks for OneDrive Web hooks for Outlook Extend Graph with your own data SDKs for .Net/Xamarin, JS/Node, Android and PHP Web hooks for users and groups Delta query scoping filter for AAD Batching
  51. 51. SharePoint Saturday Belgium 2017 • October 21 • Brussels Track: Developer| Level: 200 Extend your development skills set using MS Graph Yannick Borghmans
  52. 52. SharePoint Saturday Belgium 2017 • October 21 • Brussels Thank You!
  53. 53. Feedback http://spsbe.be

×