Since the launch of the Microsoft Graph, a ton of new possibilities are being made available to the Office 365 and SharePoint Developers. The unified API of all the Office 365 is one of the greatest Microsoft innovation of the last few years and is changing the way that solutions are built on Office 365 and SharePoint Online. The launch of the SharePoint endpoints on the Microsoft Graph will enhance our development story and lead to amazing cloud solutions.
This session is a deep-dive into the Microsoft Graph by analyzing the current /v1.0 version of the API and what is coming on the future /beta endpoint. The focus of the session will be on the SharePoint-specific features that the Graph is now offering to the SharePoint developers.
This very demo-intensive session will make sure that at the end you get those 3 key takeaways :
- Understand the role of the Microsoft Graph in the Office 365 ecosystem
- Leverage and interact with your SharePoint data from the Microsoft Graph
- Change the way you will think for your next SharePoint Online solution
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
/me/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();
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. Getting the valo of an OpenType
GET
https://graph.microsoft.com/beta/me/contacts/ID?expand=Extensions($filter=Id
eq 'Contacts.Extensions.LinkedIn')
{
…
"extensions": [
{
"@odata.type": "#microsoft.graph.openTypeExtension",
"extensionName": "Contacts.Extensions.LinkedIn",
"linkedInUrl": https://www.linkedin.com/in/seb/
}
]
}
29. 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"
]
}
30. Adding a schema extension data
POST https://graph.microsoft.com/beta/me/contacts/ID
{
"linkedin_information": {
"linkedInUrl": "https://www.linkedin.com/in/seb/"
}
}
34. 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