This session is created with developers in mind. We often have the need to access and use data stored in multiple Office 365 workloads in our custom applications, and Microsoft Graph API enables that we do that using single authentication and single service endpoint. The session will be comprehensive overview of development against Microsoft Graph APIs on both released and beta endpoint, and will provide examples of: application configuration, using REST calls and using Graph SDK.
9. Microsoft Graph Data
Active Directory
Users
profile
photo
direct reports
Groups
members
conversations
SharePoint
Sites
Lists
OneDrive
Files
upload
download
copy
versions
Outlook
Mail
messages
folders
send message
Calendar
events
find times
Excel
OneNote
Planner
Contacts
Directory
Beta
Teams
Insights
Project Rome
Devices
Activities
Intune
Reports
…and much more
12. • 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
Calling the API
/{version} ?{query-parameters}/{resource}/{id}/{property}
15. With Microsoft Graph
content
GET /me/drive/root/…
"value" : [
{"name": "proposal.pptx",… },
{"name": "forecast.xlsx",… }
]
GET /drives/items/{id}/workbook
GET /me/messages
GET /me/events
GET /me/contacts
GET /me/onenote/notebooks
GET /me/planner/tasks
GET /me/devices
GET /sites:/teams/opg:/
GET /sites:/teams/opg:/lists
GET /groups/{id}/conversations
Email
Documents
Contacts
Calendar
Tasks
Meetings
Sites
16. With Microsoft Graph
insights
GET /me/insights/trending
"value" : [
{"name": "presentation.pptx", …},
{"name": "forecast.xlsx", …}
]
GET /me/drive/recent
"value" : [
{"name": "guidelines.pptx", …},
{"name": "budget.xlsx", …}
]
GET people/?$search="topic: planning"
"value" : [
{"displayName": "Dan", …},
{"displayName": "Sean", …},
]
POST: /me/findMeetingTimes
{
"attendees": [
{
"type": "required",
"emailAddress": {
"address": "ana@contoso.com"
}
],
"meetingDuration": "2h"
}
Trending
Documents
People I’m
working with
Find me the
best time to
meet Ana
Out of office
Search people
based on topics
Recent
Documents
19. With Microsoft Graph
notifications
track changes
GET/me/mailFolders/{id}/messages/delta
"@odata.deltalink":"me/mailfolders('AA')/messages
/delta?$deltatoken=BB",
"value" : […]
POST /subscriptions
{
"changeType": "created,updated",
"notificationUrl": "https://app.net/callback",
"resource": "/me/mailfolders('AA')/messages",
}
GET/me/mailFolders/{id}/messages/delta
?$deltatoken=BB"
"value" : […]
Edited
a file
Got a new
hire
Added a new
member to a group
Scheduled a
new meeting
Got high
important email
20. Extending Microsoft Graph
extensions
Open Extensions
GET /me/message/<id>/?$expand=extensions
{
"displayName": “Mike",
"extensions": [
{
"extensionName": "Com.Contoso.Referral",
"companyName": "Wingtip Toys",
"expirationDate": "2017-12-30T11",
"dealValue": 10,000
}
]
}
Schema extensions
POST /schemaExtensions
{
"id": "training_courses",
"targetTypes": [ "Group" ],
"properties": [
{
"name": "courseName",
"type": "String"
}…
]
}
GET /groups?$filter=courses/name eq Math101
Customer
referral email
Carlo’s son:
Johnny
Favorite color: blue
Group:
Math 101
21. Common queries
Scenario API - https://graph.microsoft.com/
GET my profile /v1.0/me
GET my files /v1.0/me/drive/root/children
GET my photo /v1.0/me/photo/$value
GET my high importance email /v1.0/me/messages?$filter=importance eq 'high'
GET my calendar /v1.0/me/calendar
GET my manager /v1.0/me/manager
GET last user to modify foo.txt /v1.0/me/drive/root/children/foo.txt/lastModifiedByUser
GET my recent files /v1.0/me/drive/recent
GET Office 365 groups I’m member of /v1.0/me/memberOf/$/?$filter=groupTypes/any(a:a eq 'unified')
GET users in my organization /v1.0/users
GET group conversations /v1.0/groups/<id>/conversations
GET people relevant to me /v1.0/me/people
GET files trending around me /beta/me/insights/trending
GET the root SharePoint site /v1.0/sharepoint/sites/root
GET my Planner tasks /v1.0/me/planner/tasks
GET my notes /v1.0/me/onenote/notebooks
22. Demo
Using REST in ASP.NET MVC app
and Angular app
https://github.com/panjkov/Office365PlannerTask
https://github.com/panjkov/angular2files
23. Azure AD auth endpoints
Work and school Personal
with ADAL
24. App type
Who can
consent
Permissions
of the request
Permissions
Get access on behalf of users Get access as a service
Mobile, Web and Single page app Service and Daemon
Users can consent
for their data
Admin can consent
for them or for all users
Only admin
can consent
App
permissions
User
permissions
App
permissions
26. SDKs, samples and tooling
https://www.nuget.org/packages/Microsoft.Graph
27. Auth
access_token
Register your app at https://apps.dev.microsoft.com
MSAL
YOUR APP
Microsoft
Graph
id_token
access_token refresh_token
Microsoft
Identity
29. Service specific endpoints:
Available and supported
Require resource specific access tokens
Microsoft Graph:
Simplest way to access data in Office 365
and other Microsoft cloud services
Microsoft Graph API vs. Service APIs
https://graph.microsoft.com
Your app Your app
Outlook Azure ADSharePoint …
30. Calling SharePoint REST APIs
Get access token to call Microsoft Graph
POST https://login.microsoftonline.com/common/oauth2/token?client_id=123…
&scope=graph.microsoft.com
Call Microsoft Graph to discover the SharePoint RootSite:
GET https://graph.microsoft.com/v1.0/sites/root/sharepointIds/siteUrl
Use refresh token to get an access token for SharePoint
POST https://login.microsoftonline.com/common/oauth2/token?client_id=123…
&resource={siteURL}
Call SharePoint endpoint
GET {siteURL}/_api/web/navigation/quicklaunch
(*) Only supported in v1.0 auth
33. Imagine what you can build
Smart Meetings
Custom Dashboards
Intelligent Business Process
Smart Pickers
Graph-Powered Bots
Graph-Connected Devices
… and MORE
34. Microsoft Graph Community Call
https://techcommunity.microsoft.com/t5/SharePoint/Mark-your-Calendars-The-First-Microsoft-Graph-
Community-Call-is/m-p/133037
aka.ms/MicrosoftGraphCall