SlideShare a Scribd company logo
Webinar Series: Getting Started with SharePoint Framework
Getting Started with
SharePoint Framework
Webinar Series
Webinar Series: Getting Started with SharePoint Framework
Consume Graph APIs in
SharePoint Framework
Webinar Series: Getting Started with SharePoint Framework
Jenkins NS
Modern Workplace Solution Architect | Consultant
Founder & Director @
Microsoft Teams, Power Platform and SPFx Specialist
International Speaker | Blogger | Trainer
SPS Bangalore Organizer
aOS Ambassador
@jenkinsns
https://www.facebook.com/msteamsinfo
in/jenkinsns
jenkinsns@gmail.com
http://www.jenkinsblogs.com
jenkinsns
https://www.facebook.com/spfxinfo/
Webinar Series: Getting Started with SharePoint Framework
Agenda
 Overview of MS Graph
 Office 365 APIs
 What is Graph API?
 Consume Microsoft Graph
 AadHttpClient object
 MSGraphClient object
 API permissions requests
 Isolated web parts
 Demo
Webinar Series: Getting Started with SharePoint Framework
Office 356 APIs
Service Functionality Base URL
Azure AD Graph
User, Groups Application,
Devices
https://graph.windows.net
Exchange Online Mail, Calendar, Contacts https://outlook.office365.com/api
SharePoint Online
List, Libraries, Search, User
Profiles
https://tenant.sharepoint.com/_api
OneDrive for
Business
Files, Folders https://tenant-my.sharepoint.com/_api
OneNote Notebooks,Pages https://onenote.com/api
Yammer Conversations https://yammer.com/api
Stream Videos, Channels https://tenant.sharepoint.com/portals
Webinar Series: Getting Started with SharePoint Framework
STANDALONE
WEB, DEVICE,
AND SERVICE
APPS
EXTENSIONS
EMBEDDED CANVASES
Microsoft Graph External Data & Content
Conversation are Core to the Office 365 Platform
Webinar Series: Getting Started with SharePoint Framework
Overview of Microsoft Graph
Webinar Series: Getting Started with SharePoint Framework
What is Graph API?
Microsoft Graph exposes REST APIs and client libraries to access data on the
following Microsoft 365 services:
Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive,
OneNote, Outlook/Exchange, Planner, and SharePoint
Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat
Protection, Azure Active Directory, Identity Manager, and Intune
Windows 10 services: activities, devices, notifications
Dynamics 365 Business Central
Webinar Series: Getting Started with SharePoint Framework
SharePointGroups
Microsoft Graph
Access user, group and organizational data
One endpoint
One token
All users
Your App
https://graph.microsoft.com
#SPTechCon
Users Azure ADOutlook OneNote Planner Teams Excel Intune More…
Webinar Series: Getting Started with SharePoint Framework
Consume Microsoft Graph
You can now implement the below methods to consume the Microsoft Graph. You have two
options:
1. Use the AadHttpClient client object
2. Use the MSGraphClient client object
SharePoint Framework v1.6.0 onwards supported consuming the MS Graph APIs and custom
APIs.
Note:
 SharePoint Framework v1.4.1 beta onwards MS Graph APIs supported.
 You can consume the Microsoft Graph API with versions of SharePoint Framework earlier than v.1.4.1, either via the
native graphHttpClient, or via a manual ADAL JS implicit OAuth flow.
Webinar Series: Getting Started with SharePoint Framework
AadHttpClient
AadHttpClient
The AadHttpClient client object is useful for consuming any REST API. You can use it to consume Microsoft Graph or any other third-party
(or first-party) REST API and “AadHttpClient” is used to perform REST calls against an Azure AD Application, for example 3rd party WebAPI
hosted in Azure.
 For communicating with SharePoint, use the “SPHttpClient” class instead.
 For communicating SharePoint with Microsoft Graph, use the MSGraphClient class.
this.props.context.aadHttpClientFactory
.getClient('https://graph.microsoft.com’)
.then((client: AadHttpClient) => {
// Search for the users with givenName, surname, or displayName equal to the searchFor value
return client .get(
`https://graph.microsoft.com/v1.0/users?$select=displayName,mail,userPrincipalName&$filter=(givenName%20eq%20'${escape(this.state.searchFor)}')%20or%20(sur
name%20eq%20'${escape(this.state.searchFor)}')%20or%20(displayName%20eq%20'${escape(this.state.searchFor)}')`, AadHttpClient.configurations.v1
);
})
.then(response => {
return response.json();
})
Webinar Series: Getting Started with SharePoint Framework
MSGraphClient object
MSGraphClient
“MSGraphClient” is used to perform REST calls against Microsoft Graph. The Microsoft Graph JavaScript client library is a lightweight wrapper around
the Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without needing to initialize the MSGraph client library.
 The MSGraphClient client object can consume the Microsoft Graph only. Internally it uses the AadHttpClient client object and supports the fluent
syntax of the Microsoft Graph SDK.
 Supported from SPFx v1.4.1 (Initial beta release of MSGraphClient class)
 MSGraphClient is a new HTTP client introduced in SharePoint Framework v1.6.0
this.props.context.msGraphClientFactory
.getClient()
.then((client: MSGraphClient): void => {
// From https://github.com/microsoftgraph/msgraph-sdk-javascript sample
client
.api("users")
.version("v1.0")
.select("displayName,mail,userPrincipalName")
.filter(`(givenName eq '${escape(this.state.searchFor)}') or (surname eq '${escape(this.state.searchFor)}') or (displayName eq
'${escape(this.state.searchFor)}')`)
.get((err, res) => {
if (err) { console.error(err); return; }
Webinar Series: Getting Started with SharePoint Framework
API Permissions
 To consume Microsoft Graph or any other third-party REST API, you need to explicitly declare the permission requirements from an
OAuth perspective in the manifest of your solution.
 In the SharePoint Framework v.1.4.1 or later, you can do that by configuring the webApiPermissionRequests property in the
package-solution.json under the config folder of the solution.
 Microsoft Graph permission names follow a simple pattern: resource.operation.constraint..Read grants permission to read the
profile of the signed-in user.
 User.ReadWrite grants permission to read and modify the profile of the signed-in user and
 Mail.Send grants permission to send mail on behalf of the signed-in user.
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "User.ReadBasic.All"
}
]
https://docs.microsoft.com/en-us/graph/api/resources/team?view=graph-rest-1.0
Webinar Series: Getting Started with SharePoint Framework
API access
Webinar Series: Getting Started with SharePoint Framework
Isolated Webparts
Webinar Series: Getting Started with SharePoint Framework
Why Isolated web parts?
 To allow your SharePoint Framework solutions to securely access APIs secured with Azure AD, you can use the API management to
specify which APIs can be accessed by scripts in your tenant and with which permissions.
 Using the SharePoint Framework, you can easily retrieve an access token for the specific API.
 While it significantly simplifies communicating with APIs secured with Azure AD, it allows all scripts, not just specific SharePoint
Framework solutions, to obtain an access token for any of the approved APIs. If one of the scripts you use in your tenant was
exploited, then it could access any of the approved APIs on behalf of the current user.
 SharePoint Framework v1.8.0 onwards has addressed this situation by introducing isolated web parts
 Isolated web parts introduce a new way to isolate access to APIs secured with Azure AD and ensure that only specific SharePoint
Framework web parts are allowed to obtain an access token for the particular API.
 If your web part requires permission to access any backend API or Graph, it is strongly recommended to have the web part isolated.
 We should protect the access token which is used behind the scenes and make sure that no other script on the page will piggy-back
the permissions we are using. Isolated web part is one step towards handling security concerns.
Webinar Series: Getting Started with SharePoint Framework
Isolated web parts
Webinar Series: Getting Started with SharePoint Framework
Isolated web parts benefits
 Web parts from an isolated SPFx package run on a unique domain, hosted within an iFrame - the permissions granted apply only to
code hosted on that domain.
 Regular SPFx web parts run on your *.sharepoint.com domain, the granted permissions do not apply there.
 And since any other SPFx isolated web parts run on a different unique domain, they don't apply there either.
 Essentially, the shared application principal for SPFx is not used – instead, an AAD app registration dedicated to this SPFx solution is
created and used for authentication.
 Note this scope isn’t the individual web part, but the containing solution package.
 This is fine however - if you have an untrusted source contributing code to the very same solution/codebase, then you probably
have bigger security and governance challenges to deal with quite frankly.
In the ‘config/package-solution.json’ file, set the isDomainIsolated property to true.
"isDomainIsolated": true
Webinar Series: Getting Started with SharePoint Framework
Demo
SharePoint Framework
https://github.com/jenkinsns/spfx-demo-webparts
Download the code
Webinar Series: Getting Started with SharePoint Framework
References…
 http://jenkinsblogs.com/2020/04/29/retrieve-sharepoint-list-items-using-microsoft-graph-api-for-spfx/
 https://developer.microsoft.com/en-us/graph/graph-explorer#
 https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http
 https://docs.microsoft.com/en-us/graph/permissions-reference
 https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph
 https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aad-tutorial
 https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/isolated-web-parts
Webinar Series: Getting Started with SharePoint Framework
Thank You
Webinar Series: Getting Started with SharePoint Framework
Next up…
Build Microsoft Teams customizations with SPFx
Kirti Prajapati

More Related Content

PPTX
Microsoft Graph developer community call-March 2020
PPTX
Microsoft identity platform community call-May 2020
PPTX
Community call: Develop multi tenant apps with the Microsoft identity platform
PPTX
SharePoint 2013 “App Model” Developing and Deploying Provider Hosted Apps
PPTX
Developer’s Independence Day: Introducing the SharePoint App Model
PPTX
An introduction to Microsoft Graph for developers
PPTX
App Model For SharePoint 2013
PPTX
Developing With Data Technologies
Microsoft Graph developer community call-March 2020
Microsoft identity platform community call-May 2020
Community call: Develop multi tenant apps with the Microsoft identity platform
SharePoint 2013 “App Model” Developing and Deploying Provider Hosted Apps
Developer’s Independence Day: Introducing the SharePoint App Model
An introduction to Microsoft Graph for developers
App Model For SharePoint 2013
Developing With Data Technologies

What's hot (20)

PPTX
Implement Authorization in your Apps with Microsoft identity platform-June 2020
PPTX
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
PPTX
2014 SharePoint Saturday Melbourne Apps or not to Apps
PDF
Creating modern java web applications based on struts2 and angularjs
PPTX
Microsoft Graph: Connect to essential data every app needs
PPTX
Introducing the new SharePoint 2013 app model
PDF
Real World SharePoint Framework and Azure Services
PDF
Kasten securing access to your kubernetes applications
PPTX
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
PPT
Migrate To Lightning Web Components from Aura framework to increase performance
PPTX
Office 365 for Developers
PDF
Introduction to Lightning Web Components
PDF
Spunite17 Converting your CEWP Customisations
PPTX
Grow your SharePoint development platform with SPFx
PPTX
SharePoint 2013 “App Model” Developing and Deploying Provider Hosted Apps
PPTX
Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...
PPTX
Windows Phone 7 Unleashed Session 2
PPTX
SharePoint and Azure - A Match Made in the Clouds
PPTX
Windows Azure SQL Database Federations
PPTX
What’s New for Devs
Implement Authorization in your Apps with Microsoft identity platform-June 2020
Apps 101 - Moving to the SharePoint 2013 App Model - Presented 7/27/13 at Sha...
2014 SharePoint Saturday Melbourne Apps or not to Apps
Creating modern java web applications based on struts2 and angularjs
Microsoft Graph: Connect to essential data every app needs
Introducing the new SharePoint 2013 app model
Real World SharePoint Framework and Azure Services
Kasten securing access to your kubernetes applications
Tutorial: Building Apps for SharePoint 2013 Inside and Outside of the Firewal...
Migrate To Lightning Web Components from Aura framework to increase performance
Office 365 for Developers
Introduction to Lightning Web Components
Spunite17 Converting your CEWP Customisations
Grow your SharePoint development platform with SPFx
SharePoint 2013 “App Model” Developing and Deploying Provider Hosted Apps
Developing SharePoint 2013 apps with Visual Studio 2012 - SharePoint Connecti...
Windows Phone 7 Unleashed Session 2
SharePoint and Azure - A Match Made in the Clouds
Windows Azure SQL Database Federations
What’s New for Devs
Ad

Similar to harePoint Framework Webinar Series: Consume Graph APIs in SharePoint Framework (20)

PPTX
SPFx Webinar Loading SharePoint data in a SPFx Webpart
PDF
Leveraging APIs from SharePoint Framework solutions
PPTX
#SPSottawa The SharePoint Framework and The Microsoft Graph on steroids with ...
PPTX
#SPSToronto The SharePoint Framework and the Microsoft Graph on steroids with...
PPTX
SharePoint as Development Platform for the Modern Intranet
PPTX
Building SharePoint framework Web Parts using the Microsoft Graph
PPTX
SharePoint Saturday Chicago - Everything your need to know about the Microsof...
PPTX
Leveraging SharePoint as a development platform for the modern intranet
PPTX
SharePoint Fest Seattle 2017 - Everything your need to know about the Microso...
PPTX
Developing share point solutions with the microsoft graph
PPTX
SharePoint Fest DC - Everything your need to know about the Microsoft Graph a...
PPTX
Granite state #spug The #microsoftGraph and #SPFx on steroids with #AzureFunc...
PPTX
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
PPTX
APIs, APIs Everywhere!
PPTX
#SPFestSea azr302 The SharePoint Framework and the #MicrosoftGraph under ster...
PPTX
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
PPTX
2019 05-16 unchain your app's capabilities with microsft graph a os luxembourg
PDF
2019 05-16 aOS Luxembourg - 5 - Unchain your apps capabilities with Microsoft...
PPTX
SPS Utah - Everything your need to know about the Microsoft Graph as a ShareP...
PPTX
SharePoint Conference 2018 - APIs, APIs everywhere!
SPFx Webinar Loading SharePoint data in a SPFx Webpart
Leveraging APIs from SharePoint Framework solutions
#SPSottawa The SharePoint Framework and The Microsoft Graph on steroids with ...
#SPSToronto The SharePoint Framework and the Microsoft Graph on steroids with...
SharePoint as Development Platform for the Modern Intranet
Building SharePoint framework Web Parts using the Microsoft Graph
SharePoint Saturday Chicago - Everything your need to know about the Microsof...
Leveraging SharePoint as a development platform for the modern intranet
SharePoint Fest Seattle 2017 - Everything your need to know about the Microso...
Developing share point solutions with the microsoft graph
SharePoint Fest DC - Everything your need to know about the Microsoft Graph a...
Granite state #spug The #microsoftGraph and #SPFx on steroids with #AzureFunc...
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
APIs, APIs Everywhere!
#SPFestSea azr302 The SharePoint Framework and the #MicrosoftGraph under ster...
SharePoint Fest DC 2018 - Everything your need to know about the Microsoft Gr...
2019 05-16 unchain your app's capabilities with microsft graph a os luxembourg
2019 05-16 aOS Luxembourg - 5 - Unchain your apps capabilities with Microsoft...
SPS Utah - Everything your need to know about the Microsoft Graph as a ShareP...
SharePoint Conference 2018 - APIs, APIs everywhere!
Ad

More from Jenkins NS (20)

PPTX
All about Send proactive messages in Microsoft Teams BOT
PPTX
Surfacing SPFx Solutions in SharePoint, MS Teams, and Outlook Add-in
PPTX
Global M365 Developer Bootcamp 2020 Hyderabad: KEYNOTE
PPTX
Global M365 Developer Bootcamp 2020 Hyderabad: WELCOME NOTE
PPTX
SPFx Outlook add-in with Azure Cognitive services to detect the sentiment bef...
PDF
Extend the unextended in microsoft teams
PPTX
Power Automate integration with SPFX webpart
PPTX
Task-oriented interactions in Microsoft Teams with messaging extensions
PPTX
Microsoft power platform
PPTX
Introduction to microsoft teams app templates
PPTX
Build an app from scratch using teams app studio for ms teams
PPTX
Empowering citizen developers using power apps
PPTX
Ms teams webinar-getting started with microsoft teams development
PPTX
M365 virtual marathon build your first power virtual agents bot
PPTX
SPSChennai2020
PPTX
Trivandrumtechcon20
PPTX
Governance and administration for teams app development
PPTX
Getting started with spfx
PPTX
Architecting your Intranet with SharePoint Modernization
PPTX
Bots, adaptive cards, task module, message extensions in microsoft teams
All about Send proactive messages in Microsoft Teams BOT
Surfacing SPFx Solutions in SharePoint, MS Teams, and Outlook Add-in
Global M365 Developer Bootcamp 2020 Hyderabad: KEYNOTE
Global M365 Developer Bootcamp 2020 Hyderabad: WELCOME NOTE
SPFx Outlook add-in with Azure Cognitive services to detect the sentiment bef...
Extend the unextended in microsoft teams
Power Automate integration with SPFX webpart
Task-oriented interactions in Microsoft Teams with messaging extensions
Microsoft power platform
Introduction to microsoft teams app templates
Build an app from scratch using teams app studio for ms teams
Empowering citizen developers using power apps
Ms teams webinar-getting started with microsoft teams development
M365 virtual marathon build your first power virtual agents bot
SPSChennai2020
Trivandrumtechcon20
Governance and administration for teams app development
Getting started with spfx
Architecting your Intranet with SharePoint Modernization
Bots, adaptive cards, task module, message extensions in microsoft teams

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Monthly Chronicles - July 2025
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
A Presentation on Artificial Intelligence
PDF
Empathic Computing: Creating Shared Understanding
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
NewMind AI Monthly Chronicles - July 2025
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Modernizing your data center with Dell and AMD
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
A Presentation on Artificial Intelligence
Empathic Computing: Creating Shared Understanding
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

harePoint Framework Webinar Series: Consume Graph APIs in SharePoint Framework

  • 1. Webinar Series: Getting Started with SharePoint Framework Getting Started with SharePoint Framework Webinar Series
  • 2. Webinar Series: Getting Started with SharePoint Framework Consume Graph APIs in SharePoint Framework
  • 3. Webinar Series: Getting Started with SharePoint Framework Jenkins NS Modern Workplace Solution Architect | Consultant Founder & Director @ Microsoft Teams, Power Platform and SPFx Specialist International Speaker | Blogger | Trainer SPS Bangalore Organizer aOS Ambassador @jenkinsns https://www.facebook.com/msteamsinfo in/jenkinsns jenkinsns@gmail.com http://www.jenkinsblogs.com jenkinsns https://www.facebook.com/spfxinfo/
  • 4. Webinar Series: Getting Started with SharePoint Framework Agenda  Overview of MS Graph  Office 365 APIs  What is Graph API?  Consume Microsoft Graph  AadHttpClient object  MSGraphClient object  API permissions requests  Isolated web parts  Demo
  • 5. Webinar Series: Getting Started with SharePoint Framework Office 356 APIs Service Functionality Base URL Azure AD Graph User, Groups Application, Devices https://graph.windows.net Exchange Online Mail, Calendar, Contacts https://outlook.office365.com/api SharePoint Online List, Libraries, Search, User Profiles https://tenant.sharepoint.com/_api OneDrive for Business Files, Folders https://tenant-my.sharepoint.com/_api OneNote Notebooks,Pages https://onenote.com/api Yammer Conversations https://yammer.com/api Stream Videos, Channels https://tenant.sharepoint.com/portals
  • 6. Webinar Series: Getting Started with SharePoint Framework STANDALONE WEB, DEVICE, AND SERVICE APPS EXTENSIONS EMBEDDED CANVASES Microsoft Graph External Data & Content Conversation are Core to the Office 365 Platform
  • 7. Webinar Series: Getting Started with SharePoint Framework Overview of Microsoft Graph
  • 8. Webinar Series: Getting Started with SharePoint Framework What is Graph API? Microsoft Graph exposes REST APIs and client libraries to access data on the following Microsoft 365 services: Office 365 services: Delve, Excel, Microsoft Bookings, Microsoft Teams, OneDrive, OneNote, Outlook/Exchange, Planner, and SharePoint Enterprise Mobility and Security services: Advanced Threat Analytics, Advanced Threat Protection, Azure Active Directory, Identity Manager, and Intune Windows 10 services: activities, devices, notifications Dynamics 365 Business Central
  • 9. Webinar Series: Getting Started with SharePoint Framework SharePointGroups Microsoft Graph Access user, group and organizational data One endpoint One token All users Your App https://graph.microsoft.com #SPTechCon Users Azure ADOutlook OneNote Planner Teams Excel Intune More…
  • 10. Webinar Series: Getting Started with SharePoint Framework Consume Microsoft Graph You can now implement the below methods to consume the Microsoft Graph. You have two options: 1. Use the AadHttpClient client object 2. Use the MSGraphClient client object SharePoint Framework v1.6.0 onwards supported consuming the MS Graph APIs and custom APIs. Note:  SharePoint Framework v1.4.1 beta onwards MS Graph APIs supported.  You can consume the Microsoft Graph API with versions of SharePoint Framework earlier than v.1.4.1, either via the native graphHttpClient, or via a manual ADAL JS implicit OAuth flow.
  • 11. Webinar Series: Getting Started with SharePoint Framework AadHttpClient AadHttpClient The AadHttpClient client object is useful for consuming any REST API. You can use it to consume Microsoft Graph or any other third-party (or first-party) REST API and “AadHttpClient” is used to perform REST calls against an Azure AD Application, for example 3rd party WebAPI hosted in Azure.  For communicating with SharePoint, use the “SPHttpClient” class instead.  For communicating SharePoint with Microsoft Graph, use the MSGraphClient class. this.props.context.aadHttpClientFactory .getClient('https://graph.microsoft.com’) .then((client: AadHttpClient) => { // Search for the users with givenName, surname, or displayName equal to the searchFor value return client .get( `https://graph.microsoft.com/v1.0/users?$select=displayName,mail,userPrincipalName&$filter=(givenName%20eq%20'${escape(this.state.searchFor)}')%20or%20(sur name%20eq%20'${escape(this.state.searchFor)}')%20or%20(displayName%20eq%20'${escape(this.state.searchFor)}')`, AadHttpClient.configurations.v1 ); }) .then(response => { return response.json(); })
  • 12. Webinar Series: Getting Started with SharePoint Framework MSGraphClient object MSGraphClient “MSGraphClient” is used to perform REST calls against Microsoft Graph. The Microsoft Graph JavaScript client library is a lightweight wrapper around the Microsoft Graph API. This class allows developers to start making REST calls to MSGraph without needing to initialize the MSGraph client library.  The MSGraphClient client object can consume the Microsoft Graph only. Internally it uses the AadHttpClient client object and supports the fluent syntax of the Microsoft Graph SDK.  Supported from SPFx v1.4.1 (Initial beta release of MSGraphClient class)  MSGraphClient is a new HTTP client introduced in SharePoint Framework v1.6.0 this.props.context.msGraphClientFactory .getClient() .then((client: MSGraphClient): void => { // From https://github.com/microsoftgraph/msgraph-sdk-javascript sample client .api("users") .version("v1.0") .select("displayName,mail,userPrincipalName") .filter(`(givenName eq '${escape(this.state.searchFor)}') or (surname eq '${escape(this.state.searchFor)}') or (displayName eq '${escape(this.state.searchFor)}')`) .get((err, res) => { if (err) { console.error(err); return; }
  • 13. Webinar Series: Getting Started with SharePoint Framework API Permissions  To consume Microsoft Graph or any other third-party REST API, you need to explicitly declare the permission requirements from an OAuth perspective in the manifest of your solution.  In the SharePoint Framework v.1.4.1 or later, you can do that by configuring the webApiPermissionRequests property in the package-solution.json under the config folder of the solution.  Microsoft Graph permission names follow a simple pattern: resource.operation.constraint..Read grants permission to read the profile of the signed-in user.  User.ReadWrite grants permission to read and modify the profile of the signed-in user and  Mail.Send grants permission to send mail on behalf of the signed-in user. "webApiPermissionRequests": [ { "resource": "Microsoft Graph", "scope": "User.ReadBasic.All" } ] https://docs.microsoft.com/en-us/graph/api/resources/team?view=graph-rest-1.0
  • 14. Webinar Series: Getting Started with SharePoint Framework API access
  • 15. Webinar Series: Getting Started with SharePoint Framework Isolated Webparts
  • 16. Webinar Series: Getting Started with SharePoint Framework Why Isolated web parts?  To allow your SharePoint Framework solutions to securely access APIs secured with Azure AD, you can use the API management to specify which APIs can be accessed by scripts in your tenant and with which permissions.  Using the SharePoint Framework, you can easily retrieve an access token for the specific API.  While it significantly simplifies communicating with APIs secured with Azure AD, it allows all scripts, not just specific SharePoint Framework solutions, to obtain an access token for any of the approved APIs. If one of the scripts you use in your tenant was exploited, then it could access any of the approved APIs on behalf of the current user.  SharePoint Framework v1.8.0 onwards has addressed this situation by introducing isolated web parts  Isolated web parts introduce a new way to isolate access to APIs secured with Azure AD and ensure that only specific SharePoint Framework web parts are allowed to obtain an access token for the particular API.  If your web part requires permission to access any backend API or Graph, it is strongly recommended to have the web part isolated.  We should protect the access token which is used behind the scenes and make sure that no other script on the page will piggy-back the permissions we are using. Isolated web part is one step towards handling security concerns.
  • 17. Webinar Series: Getting Started with SharePoint Framework Isolated web parts
  • 18. Webinar Series: Getting Started with SharePoint Framework Isolated web parts benefits  Web parts from an isolated SPFx package run on a unique domain, hosted within an iFrame - the permissions granted apply only to code hosted on that domain.  Regular SPFx web parts run on your *.sharepoint.com domain, the granted permissions do not apply there.  And since any other SPFx isolated web parts run on a different unique domain, they don't apply there either.  Essentially, the shared application principal for SPFx is not used – instead, an AAD app registration dedicated to this SPFx solution is created and used for authentication.  Note this scope isn’t the individual web part, but the containing solution package.  This is fine however - if you have an untrusted source contributing code to the very same solution/codebase, then you probably have bigger security and governance challenges to deal with quite frankly. In the ‘config/package-solution.json’ file, set the isDomainIsolated property to true. "isDomainIsolated": true
  • 19. Webinar Series: Getting Started with SharePoint Framework Demo SharePoint Framework https://github.com/jenkinsns/spfx-demo-webparts Download the code
  • 20. Webinar Series: Getting Started with SharePoint Framework References…  http://jenkinsblogs.com/2020/04/29/retrieve-sharepoint-list-items-using-microsoft-graph-api-for-spfx/  https://developer.microsoft.com/en-us/graph/graph-explorer#  https://docs.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http  https://docs.microsoft.com/en-us/graph/permissions-reference  https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-msgraph  https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aad-tutorial  https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/isolated-web-parts
  • 21. Webinar Series: Getting Started with SharePoint Framework Thank You
  • 22. Webinar Series: Getting Started with SharePoint Framework Next up… Build Microsoft Teams customizations with SPFx Kirti Prajapati

Editor's Notes

  • #14: https://docs.microsoft.com/en-us/graph/api/resources/team?view=graph-rest-1.0 https://developer.microsoft.com/en-us/graph/graph-explorer# https://docs.microsoft.com/en-us/graph/permissions-reference