Interacting with O365 using MS Graph API “One endpoint to rule them all” Nilesh Shah, Consultant Solvera Solutions
About Me Developer/Consultant - MS .NET/Azure TOGAF 9.1 certified EA MCSD, Microsoft Specialist, MCP Certified Scrum Master (CSM), Certified Scrum Developer (CSD), Six Sigma Green Belt Founder member - C# Corner Regina, SK chapter
About Solvera Solutions HO – Regina, Offices in Western Canada Application Development Consultancy Architecture & Management Consultancy One of Canada’s Top 100 Employers One of Canada’s best managed companies AON – Best Employer – Platinum Category
Contents Overview of Microsoft Graph API Why Graph? Advantages, Features, Limitations Demo Office 365 developer program Microsoft Graph API Explorer Microsoft App Registration Portal MS Graph SDK Q & A
Why know Graph API? 85% of all Fortune 500 companies are using O365 a.k.a. little sales speech… 85% of all Fortune 500 companies are using O365 85M monthly active users on Office 365 commercial 400M Outlook.com monthly active users 8T resources (emails, events, users, files, groups, and more) in Microsoft Graph
Why MS Graph API?
Warning: Logo missing…
Many Office 365 Apps…
Resulting in scattered data… EMAIL AND CONVERSATIONS USER FILES EVENTS PEOPLE GROUPS
Requiring different endpoints… For Outlook mails, contacts, calendar https://outlook.office.com/api/v1.0/ For files from cloud https://api.onedrive.com/v1.0 Yammer https://www.yammer.com/api/v1/ OneNote https://www.onenote.com/api/v1.0/ And many more… Audience poll – how many has used any of the O365 API? What was their experience? Next slide to focus on dealing with O365 API
Calling O365/Cloud API Find the URL/endpoint of the API Authenticate/Get access token Get information from the API Repeat for each service/API Multiple token management
One endpoint to rule them all Solution… … … One endpoint to rule them all https://graph.microsoft.com
MS Graph API is… The easiest way to call Microsoft Office 365 APIs
Advantages Ease of development Single well-known resource Unified API endpoint - No more calling a different endpoint for each service No more obtaining separate tokens for different services Single well-known resource Users, Groups, Mail, Calendars, Contacts Files, Tasks, People, Notes and more — all from a single endpoint Logical navigation across item relationships Platform flexibility Audience poll for OAUTH and ODATA, slides on OAUTH and ODATA shown based on audience familiarity with these topics, otherwise can skip those slides.
Why the name - Graph? The structure looks like a graph so the name Graph API, Facebook also has graph API
Pick the platform of your choice
Features The Microsoft identity stack Used by 85% of the Fortune 500 Access intelligence and insights from the Microsoft cloud trending documents best team meeting times who people typically work with Open standards support REST JSON OAUTH 2.0 OpenID Connect ODATA V4
OAUTH Open standard for “authorization” Microsoft supports OAuth 2.0 It is not “authentication” protocol Authorize access without password Uses token after third party authentication is done Provides secured delegated access on behalf of owner Microsoft supports OAuth 2.0 Mostly all leading SM providers support it OpenID Authentication An extension to OAuth 2.0 authorization This works as identity layer Identity provider asserts identity
ODATA The Open Data Protocol “The best way to REST” URL query string operators used to identify data Simple, standard and readable expressions MS Graph API compatible with OData V4
Authorization flow
MS Graph development stack
Basic URL pattern https://graph.microsoft.com/{version}/{resource}?[query_parameters] https://graph.microsoft.com = Microsoft Graph API endpoint Version = v1.0 or beta Resource = segment or path users, groups, devices, events, etc. Alias: me (logged in user), organization query_parameters (Optional) = $top, $count, etc.
Query Parameters $top $skip $count $select $orderby Select only specific no. of items $skip Skip some items $count How many items in result $select Specific property $orderby Sort the items There are many more, outlined by OData V4 query language, but this list shows only some of them.
Application flow Register the application Microsoft App Registration Portal : https://apps.dev.microsoft.com Configure the project with ID & key Authenticate the user and get an access token Call Microsoft Graph API Show the result
Limitations New functionalities appear first in individual Office 365 REST API Some functionality not yet available Batching is not supported REST APIs in hybrid deployments (currently in preview) Some OData related limitation nextLink not supported $expand: 1 level only Show demo if possible of not supported functionality like $expand
Demo
Office 365 Developer Program https://dev.office.com/devprogram
Office 365 Developer Program https://dev.office.com/devprogram
Office 365 Developer Program
Office 365 Developer Program
Office 365 Developer Program
Office 365 Developer Program
Office 365 Developer Program
MS Graph Explorer https://graph.microsoft.io/en-us/graph-explorer Graph Explorer Permissions
Graph Explorer Permissions Show demo if possible of not supported functionality like $expand
Microsoft App Registration Portal Show demo if possible of not supported functionality like $expand
Microsoft App Registration Portal Show demo if possible of not supported functionality like $expand
Microsoft App Registration Portal Show demo if possible of not supported functionality like $expand
Microsoft App Registration Portal Show demo if possible of not supported functionality like $expand
Microsoft App Registration Portal Show demo if possible of not supported functionality like $expand
Summary
Useful Resources & Links All-in-One source: https://graph.microsoft.io/ Try It Yourself: https://graph.microsoft.io/en-us/graph-explorer https://developer.microsoft.com/en-us/graph/quick-start Watch & Learn: https://dev.office.com/videos (Graph API and more, O365 dev) Repos: https://github.com/microsoftgraph Get Your Hands Dirty: Office 365 Developer Program
Questions & Answers
Thanks to Our Sponsors!
Sponsors Special Thanks:
What’s next today @ SPS Calgary Closing and Prize Draws at 3:55pm Meet at 3:55pm at MacDonald Hall SharePint and Networking Time: 4:30pm - 6:00pm, Location TBD
Thank You!!! Sharing is caring… nilesh.shah@hotmail.com @NileshR_Shah /members/nilesh-shah9 Sharing is caring…