The document provides an overview of the Microsoft Graph and how it can be used by SharePoint developers. It discusses how the Graph provides a single endpoint for accessing and traversing Office 365 data through REST APIs and SDKs. It also covers authentication, permissions, and using the Graph Explorer, REST calls, .NET, PnP PowerShell, and JavaScript to interact with the Graph. The document describes capabilities like notifications, open extensions, and schema extensions.
6. What is the Microsoft Graph?
Single endpoint for:
1 - Accessing data
/me, /users, /groups, /messages, /drive, ….
2 -Traversing data
/drive/<id>/lastmodifiedByUser
3 - Accessing insights
/insights/trending
4-Work/School and Personal
https://graph.microsoft.com/
7. Use the Microsoft Graph to build smart apps
Gateway to data and
insights in Office365
Easy traversal of objects and
rich relationships
Web Standards, Open
Platform
Secure data access
9. Azure AD Application
• Proxy to you Office 365 data
• Enable user-consent to be
transparent with the way the
application will play with the data
• Secure protocol
• No capturing user credentials
• Fine-grained access scopes
• Long-term access through refresh
tokens
10. Permissions
• Application permissions
• Act on the Microsoft Graph as a Deamon
• Authentication is certificate-based
• Delegated permissions
• Act on the Microsoft Graph as an authenticated user
• 60+ delegated permissions
• Does not replace the actual permissions on the data
13. Acting on the graph
• Getting Graph data
• Creating Graph data
• Updating Graph data
• Deleting Graph data
• Executing actions on the Graph
14. Acting on the Graph
GET https://graph.microsoft.com/v1.0/me
POST https://graph.microsoft.com/v1.0/groups
{
…
}
PATCH https://graph.microsoft.com/v1.0/groups/<id>
DELETE https://graph.microsoft.com/v1.0/groups/<id>
POST https://graph.microsoft.com/v1.0/me/sendMail
15. Exploring the Graph
• Using the Graph Explorer
• Using REST HTTP Calls
• Using .NET
• Using PnP PowerShell
• Using JavaScript
• Using the SDKs
17. Using REST HTTP Calls
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25j…
Accept: application/json
GET https://graph.microsoft.com/v1.0/me
GET https://graph.microsoft.com/v1.0/me/messages
GET https://graph.microsoft.com/v1.0/me/drive/root/children
GET
https://graph.microsoft.com/v1.0/groups?$filter=groupTypes/a
ny(c:c+eq+'Unified')
GET https://graph.microsoft.com/beta/me/trendingAround
GET https://graph.microsoft.com/beta/me/plans
18. Using REST HTTP Calls (SharePoint)
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25j…
Accept: application/json
GET https://graph.microsoft.com/beta/sharePoint/sites
GET https://graph.microsoft.com/beta/sharePoint/site
GET https://graph.microsoft.com/beta/sharePoint:/site/lab
GET https://graph.microsoft.com/beta/sharePoint/site/lists
GET https://graph.microsoft.com/beta/sharePoint/site/lists/<id>/items
GET https://graph.microsoft.com/beta/sharePoint/site/drives
GET https://graph.microsoft.com/beta/sharePoint/site/lists/<id>/drive
GET https://graph.microsoft.com/beta/sharePoint/site/lists/<id>/drive/root/children
19. Using .NET
var me = graphServiceClient.Me.Request().GetAsync();
var calendar = await graphServiceClient
.Me
.Calendar
.Request()
.Select("id")
.GetAsync();
var children = await graphServiceClient
.Me
.Drive
.Root
.Children
.Request()
.Expand("thumbnails")
.GetAsync();
var children = await graphServiceClient .Me .Drive .Items[itemId] .Children .Request() .Expand("thumbnails") .GetAsync();
24. Creating a webhook on the Graph
POST https://graph.microsoft.com/beta/subscriptions
{
"changeType": "Created",
"notificationUrl": "https://<url>/api/webhookCallback",
"resource": "me/messages"
}
25. Being notified from a webhook
POST https://<url>/api/webhookCallback
{
"value":[
{
"subscriptionId":"7f105c7d-2dc5-4530-97cd-4e7af6534c07",
"subscriptionExpirationDateTime":"2015-11-20T18:23:45.9356913Z",
"changeType":"Created",
"resource":"Users/<user-id>/messages/<message-id>",
"resourceData":{
"@odata.type":"#Microsoft.Graph.Message",
"@odata.id":"Users/<user-id>/messages/<message-id>",
"@odata.etag":"W/"CQAAABYAAACoeN6SYXGLRrvRm+CYrrfQAACvvGdb"",
"Id“:"<message-id>"
}
}
]
}
27. Open type extensions
POST https://graph.microsoft.com/beta/me/contacts/ID/extensions
{
"@odata.type": "Microsoft.Graph.OpenTypeExtension",
"extensionName": "Contacts.Extensions.LinkedIn",
"linkedInUrl": "https://www.linkedin.com/in/seb/"
}
28. Defining a schema extension
POST https://graph.Microsoft.com/beta/schemaExtensions
{
"id": "linkedin_information",
"description": "All information about LinkedIn account",
"targetType": ["Contacts"],
"available": "Online",
"properties" : [
"name": "linkedInUrl",
"type": "String"
]
}
29. Adding a schema extension data
POST https://graph.microsoft.com/beta/me/contacts/ID
{
"linkedin_information": {
"linkedInUrl": "https://www.linkedin.com/in/seb/"
}
}
33. Share your experience
• Use hashtags to share your experience
• #Office365Dev
• #MicrosoftGraph
• Contribute and ask question to the MicrosoftTech Community
• https://slevert.me/tech-community-sp-dev
• Log issues & questions to the GitHub Repositories