>> Consuming data through
Microsoft's Graph SharePoint pages
with SharePoint framework, it's not a breeze.
Hi. My name is Luca,
and I am a PM in the SharePoint Product Group.
Starting with release 1.4 of the SharePoint framework,
we introduce new capabilities and functionalities
to help developer connecting to the Microsoft Graph,
consuming data by using
Microsoft Graph and other web API,
as well as configure permissions
inside their application.
Lastly, we also introduce
functionalities and capabilities to
administrators to be able to
manage these kind of permission
in within their tenancies.
MSGraphClient is a class provided by
the SharePoint framework that developers can
use within their code.
It wraps the Microsoft Graph Javascript Client Library,
and handle authentication transparently by
using ADAL.js library functionality.
It also fully supports
Microsoft Graph TypeScript Types to help
you in finding error
and troubleshooting your code faster.
To consume Microsoft Graph or any other web API,
you need to explicitly
declare the permission requirements.
Starting from 1.4.1 of the SharePoint framework,
developers can configure
required permission scopes directly in
their solutions by configuring
their web API permission
requests property in the Config file.
The format is quite intuitive.
You simply specify the name of the API,
Microsoft Graph and the required scopes.
Other than that, everything is done.
The system will take care and interact with
the administrator to grab the permission by itself.
Once the solution has been packaged and deployed,
Tenant Administrator can use
SharePoint User Interface to
review and consent for the required permissions.
No unfamiliar user interfaces
are needed to access PowerShell;
everything can be performed
directly from SharePoint Tenant Administration.
Now, let's see that in action.
Here I am, we use this to decode,
and this example I'm using a web path to
access user information by using Microsoft Graph.
As you can see here,
the code is quite simple;
specified the endpoint in
Microsoft Graph that they want to use,
the version and the information that they want to
retrieve. That's pretty much it.
The libraries will take care of everything by themselves.
In the package of the configuration of the solution,
I also specify which kind of permissions scopes that I
need in order to perform my operation inside my code.
In this example, I am accessing Microsoft Graph,
and I'm access to the users
that read basic that all permission scopes.
I've now compiled and packaged my solution,
and my solution is ready to be deployed.
As a Tenant Administrator,
I go to the app catalog and I
simply take the package
and drag the package inside the app catalog.
By doing this, the system recognize that
this solution in the package require access to web APIs,
and invites me to point to
a page where I will be able to go
there and approve or reject
this kind of permissions that the application requires.
While I'm here, I'm also selecting this option to make
the solution available immediately
across all the site collection in the tenancy.
I click "Deploy", and then
I go to the SharePoint Admin Center.
Here, I have a new option called "API Management".
Once I'm here, I can see
that the permission User.ReadBasic.All
for the Microsoft Graph endpoint are
available here for me to be approved or rejected.
Those are if you remember,
the same permission that as a developer,
I would specify inside the Config file.
I simply select this item,
I click on "Approve" or "Reject" and I click
"Approve". Now, I'm done.
You can see that the system
recognized that I approved the permissions,
and the permission are ready
to be used by my application.
I go to a model page that I previously created;
I did that model page.
I go to the toolbox
and select the new web path that I created.
Once the web path is available,
here, I type the name that I want to search for.
By using the power of Microsoft Graph,
I'm able to retrieve the information
from the director service.