{"id":4776,"date":"2020-06-15T10:19:45","date_gmt":"2020-06-15T17:19:45","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=4776"},"modified":"2020-06-15T10:19:45","modified_gmt":"2020-06-15T17:19:45","slug":"a-lap-around-microsoft-graph-toolkit-day-9-microsoft-graph-toolkit-sharepoint-provider","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/a-lap-around-microsoft-graph-toolkit-day-9-microsoft-graph-toolkit-sharepoint-provider\/","title":{"rendered":"A Lap around Microsoft Graph Toolkit Day 9 \u2013 Microsoft Graph Toolkit SharePoint Provider"},"content":{"rendered":"<p>Author: Hugo Bernier, Office developer MVP<\/p>\n<p><a href=\"https:\/\/twitter.com\/bernierh\">@bernier<\/a> | <a href=\"https:\/\/github.com\/hugoabernier\">GitHub<\/a> | <a href=\"https:\/\/www.linkedin.com\/in\/bernierh\">LinkedIn<\/a><\/p>\n<h2>Introduction<\/h2>\n<p>Season 1 of our A <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/announcing-a-lap-around-microsoft-graph-toolkit-blog-series\/\">Lap around Microsoft Graph Toolkit<\/a> was all about getting started with the Microsoft Graph Toolkit. We explored how to use it when creating a web application. We configured, styled, and templated toolkit components. We used mgt-get to call the Microsoft Graph &#8211; and we explained how providers work.<\/p>\n<p>If you\u2019re a SharePoint developer, you may have thought: \u201cThat\u2019s great, but I don\u2019t want to write a web application, I want to write SharePoint solutions!\u201d.<\/p>\n<p>The great news is that most of what we\u2019ve covered so far will work inside of your SharePoint Framework (SPFx) solutions \u2013 with very few changes!<\/p>\n<p>In today\u2019s post, we\u2019ll show you how you can apply what you\u2019ve learned so far in your own SPFx solutions.<\/p>\n<h3>From an HTML application to a SharePoint Framework solution<\/h3>\n<p>As Elise explained on <a href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-365\/blogs\/a-lap-around-microsoft-graph-toolkit-day-2-zero-to-hero\/\">Day 2<\/a>, if you want to create an HTML application with MGT, follow these steps:<\/p>\n<ol>\n<li>Register your application<\/li>\n<li>Create your application<\/li>\n<li>Add Microsoft Graph Toolkit to your application<\/li>\n<li>Add the MSAL Provider<\/li>\n<li>Add the login component<\/li>\n<li>Add additional components<\/li>\n<\/ol>\n<p>We\u2019ll follow <em>almost<\/em> the same steps to create our SPFx solution.<\/p>\n<p>Let\u2019s get started!<\/p>\n<h3>Step 1: Register your application<\/h3>\n<p>When you build an HTML application, you create a new application registration in Azure Active Directory so that you can generate a unique application ID (also known as a <em>client<\/em> ID). You use the application ID to grant access to the various Microsoft Graph APIs that the MGT components in your application will use.<\/p>\n<p>When you build a SharePoint solution, it works a little differently; every solution package you create automatically generates a unique ID that is ultimately used to grant access to Microsoft Graph APIs.<\/p>\n<p>So for now, we don\u2019t need to do anything. (Don\u2019t you love it when instructions start with \u201cStep 1: Do nothing\u201d?)<\/p>\n<h3>Step 2: Create your application<\/h3>\n<p>To create a SharePoint Framework web part application, we\u2019ll use the Yeoman SharePoint generator. If you don\u2019t already have it installed, you should follow the steps to <a href=\"https:\/\/docs.microsoft.com\/en-us\/sharepoint\/dev\/spfx\/set-up-your-development-environment\">set up your SharePoint Framework development environment<\/a>.<\/p>\n<p>We\u2019ll use the standard steps to create a new web part project. Using your favorite command shell, do the following :<\/p>\n<ol>\n<li>Create a new project directory in your favorite location.<\/li>\n<\/ol>\n<pre class=\"striped:true marking:true ranges:true nums-toggle:true lang:null decode:true lang: \">md helloworld-mgt<\/pre>\n<p>2. Go to the project directory.<\/p>\n<pre class=\"lang: decode:true \">cd helloworld-mgt<\/pre>\n<p>3. Create a new HelloWorld web part by running the <a href=\"https:\/\/docs.microsoft.com\/en-us\/sharepoint\/dev\/spfx\/toolchain\/scaffolding-projects-using-yeoman-sharepoint-generator\">Yeoman SharePoint Generator<\/a>.<\/p>\n<pre class=\"lang: decode:true \">yo @microsoft\/sharepoint<\/pre>\n<p>4. When prompted:<\/p>\n<ul>\n<li>Accept the default\u00a0<strong>helloworld-mgt<\/strong>\u00a0as your solution name, and then select Enter.<\/li>\n<li>Select\u00a0<strong>SharePoint Online only (latest)<\/strong>, and select Enter.<\/li>\n<li>Select\u00a0<strong>Use the current folder<\/strong>\u00a0for where to place the files.<\/li>\n<li>Select\u00a0<strong>N<\/strong>\u00a0to not allow the solution to be deployed to all sites immediately.<\/li>\n<li>Select\u00a0<strong>Y<\/strong>\u00a0on the question if solution contains unique permissions. We\u2019ll use this later to declare which Microsoft Graph APIs we\u2019ll need to access.<\/li>\n<li>Select\u00a0<strong>WebPart<\/strong>\u00a0as the client-side component type to be created.<\/li>\n<\/ul>\n<p>5. The next set of prompts ask for specific information about your web part:<\/p>\n<ul>\n<li>Use\u00a0<strong>HelloMGT<\/strong>\u00a0as your web part name, and then select Enter.<\/li>\n<li>Accept the default\u00a0<strong>HelloMGT<\/strong>\u00a0as your web part description, and then select Enter.<\/li>\n<li>Accept the default\u00a0<strong>No javascript web framework<\/strong>\u00a0as the framework you would like to use, and then select Enter.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4777\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G1-1024x664.png\" alt=\"Display of yo sharepoint selections in terminal\" width=\"650\" height=\"422\" \/><\/p>\n<p>At this point, Yeoman installs the required dependencies and scaffolds the solution files along with the\u00a0<strong>HelloMGT<\/strong>\u00a0web part. This might take a few minutes.<\/p>\n<p>When the scaffold is complete, you should see the following message indicating a successful scaffold.<\/p>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4778\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G2-1024x342.png\" alt=\"Display of successfully scaffolded project in terminal\" width=\"650\" height=\"217\" \/><\/p>\n<p>Before we add MGT to our project, we need to make sure that the project uses TypeScript 3.7. \u00a0If you don\u2019t, you\u2019ll get these nasty error messages later:<\/p>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4779\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G3-1024x342.png\" alt=\"Display of possible errors before adding typescript 3.7 in terminal\" width=\"650\" height=\"217\" \/><\/p>\n<p>To avoid getting the messages, add TypeScript 3.7 to the solution by typing the following command:<\/p>\n<pre class=\"lang: decode:true \">npm install @microsoft\/rush-stack-compiler-3.7 --save-dev<\/pre>\n<p>Finally, use your favorite code editor (I use <a href=\"https:\/\/code.visualstudio.com\/Download\">Visual Studio Code<\/a>) to open the newly created solution\u2019s\u00a0 <span class=\"lang: decode:true crayon-inline \">tsconfig.json<\/span>\u00a0 file and look for a line that starts with <span class=\"lang: decode:true crayon-inline \">&#8220;extends&#8221;<\/span>\u00a0:, like this one:<\/p>\n<pre class=\"lang: decode:true \">\"extends\": \".\/node_modules\/@microsoft\/rush-stack-compiler-3.3\/includes\/tsconfig-web.json\",<\/pre>\n<p>and replace it with:<\/p>\n<pre class=\"lang: decode:true \">\"extends\": \".\/node_modules\/@microsoft\/rush-stack-compiler-3.7\/includes\/tsconfig-web.json\",<\/pre>\n<p>Now we\u2019re ready to add the Microsoft Graph Toolkit to our solution.<\/p>\n<h3>Step 3: Add Microsoft Graph Toolkit to your application<\/h3>\n<p>You may remember than in order to add the MGT to our HTML application, we had to add the following script to our HTML page:<\/p>\n<pre class=\"lang: decode:true \">&lt;script src=\"https:\/\/unpkg.com\/@microsoft\/mgt\/dist\/bundle\/mgt-loader.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>But since our SPFx project uses Node.js, we\u2019ll add MGT by installing the <span class=\"lang: decode:true crayon-inline \">@microsoft\/mgt npm<\/span>\u00a0 package.<\/p>\n<p>To do so, type the following command:<\/p>\n<pre class=\"lang: decode:true \">npm install @microsoft\/mgt<\/pre>\n<p>Next, we\u2019ll add our SharePoint provider.<\/p>\n<h3>Step 4: Add the SharePoint Provider<\/h3>\n<p>When we created the HTML application, we used the MSAL provider to enable authentication and Microsoft Graph access for the components.<\/p>\n<p>We did that by adding the following line to our HTML:<\/p>\n<pre class=\"lang: decode:true \">&lt;mgt-msal-provider client-id=\"[YOUR-CLIENT-ID]\"&gt;&lt;\/mgt-msal-provider&gt;<\/pre>\n<p>For SharePoint projects, we\u2019ll use the SharePoint provider. To do so, follow these steps:<\/p>\n<ol>\n<li>Open your <span class=\"lang: decode:true crayon-inline \">src\\webparts\\helloMgt\\HelloMgtWebPart.ts<\/span>\u00a0 file in your code editor.<\/li>\n<li>At the top of the file after the last <span class=\"lang: decode:true crayon-inline \">import<\/span>\u00a0line (it should be on line 10 or 11), add the following code:\n<span class=\"lang: decode:true crayon-inline \">import { Providers, SharePointProvider } from &#8216;@microsoft\/mgt&#8217;;<\/span><\/li>\n<li>In the same file, insert the following code before the <span class=\"lang: decode:true crayon-inline \">public render(): void {<\/span>\u00a0 line:\n<span class=\"lang: decode:true crayon-inline \">protected async onInit() {<\/span>\n<span class=\"lang: decode:true crayon-inline\">\u00a0 Providers.globalProvider = new SharePointProvider(this.context);<\/span>\n<span class=\"lang: decode:true crayon-inline \">}<\/span><\/li>\n<\/ol>\n<p>As you may remember from our <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/a-lap-around-microsoft-graph-toolkit-day-7-microsoft-graph-toolkit-providers\/\">Day 7<\/a> article, providers enable components to call the Microsoft Graph to retrieve and render data. When your app authenticates a user with a provider, it sets that provider as the <em>global provider <\/em>and notifies the components that the state has changed. The components then use the global provider to call the Microsoft Graph.<\/p>\n<p>In the case of a SharePoint application, we use the web part\u2019s context to initialize the <span class=\"lang: decode:true crayon-inline\">SharePointProvider<\/span>.<\/p>\n<h3>Step 5: Add the login component<\/h3>\n<p>In an HTML application, we need to use the <span class=\"lang: decode:true crayon-inline \">mgt-login<\/span>\u00a0 component to give a way to users to login because the web pages often start as anonymous and require users to log-in.<\/p>\n<p>SharePoint web parts, on the other hand, always exist in an authenticated context; we don\u2019t need people to log-in, because they already <em>had <\/em>to log-in to get to the page that hosts your web part.<\/p>\n<p>So\u2026 we don\u2019t have to do anything in this step!<\/p>\n<h3>Step 6: Add additional components<\/h3>\n<p>Now we\u2019re ready to add MGT components to our web part. All you need to do is to write the HTML you want in the render method. For example, if you wanted to use the <span class=\"lang: decode:true crayon-inline \">mgt-person<\/span> and\u00a0 <span class=\"lang: decode:true crayon-inline \">mgt-agenda<\/span>\u00a0 components, you\u2019d use the following code:<\/p>\n<pre class=\"lang: decode:true\">public render(): void {\n  this.domElement.innerHTML = `\n    &lt;mgt-person person-query=\"me\" show-name show-email&gt;&lt;\/mgt-person&gt;\n    &lt;mgt-agenda&gt;&lt;\/mgt-agenda&gt;\n  `;\n}<\/pre>\n<p>From here, you can use all the tricks you learned in\u00a0<a href=\"https:\/\/developer.microsoft.com\/en-us\/microsoft-365\/blogs\/a-lap-around-microsoft-graph-toolkit-day-3-microsoft-graph-toolkit-components\">Day 3<\/a>,\u00a0<a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/a-lap-around-microsoft-graph-toolkit-day-4-customizing-components\/\">4<\/a>,\u00a0<a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/a-lap-around-microsoft-graph-toolkit-day-5-customizing-components-using-templates\/\">5<\/a>, and <a href=\"https:\/\/developer.microsoft.com\/en-us\/graph\/blogs\/a-lap-around-microsoft-graph-toolkit-day-6-the-power-of-mgt-get\/\">6<\/a>\u00a0\u00a0to use the MGT components in whichever way you need.<\/p>\n<p>Next, we\u2019ll need to prepare our web part and deploy it!<\/p>\n<h3>Step 7: Build Solution<\/h3>\n<p>Before we can use the web part, we need to declare which Microsoft Graph API permissions we\u2019ll need and deploy it.\u00a0 To do so, follow these steps:<\/p>\n<ol>\n<li>Open <span class=\"lang: decode:true crayon-inline \">config\\package-solution.json<\/span>\u00a0 using your code editor<\/li>\n<li>Look for a line that starts with <span class=\"lang: decode:true crayon-inline \">&#8220;isDomainIsolated&#8221;<\/span>\u00a0and change it from:\n<span class=\"lang: decode:true crayon-inline \">&#8220;isDomainIsolated&#8221;: true,<\/span>\nto:\n<span class=\"lang: decode:true crayon-inline \">&#8220;isDomainIsolated&#8221;: false,<\/span><\/li>\n<li>Just below the line you just change, add the following lines:\n<span class=\"lang: decode:true crayon-inline \">&#8220;webApiPermissionRequests&#8221;: [<\/span>\n<span class=\"lang: decode:true crayon-inline \">],<\/span><\/li>\n<li>Determine which Microsoft Graph API permissions you\u2019ll need. You can do this by looking at the documentation for every component you use in your solution and look at the <strong>Permissions <\/strong> For example, if you\u2019re using the <span class=\"lang: decode:true crayon-inline \">mgt-agenda<\/span>\u00a0 component, you\u2019ll need <span class=\"lang: decode:true crayon-inline \">Calendars.Read<\/span>\u00a0.<\/li>\n<li>For every permission you need, add it to the webApiPermissionRequests, as follows:\n<pre class=\"lang: decode:true \">\"webApiPermissionRequests\": [ \n  {\n    \"resource\": \"Microsoft Graph\", \n    \"scope\": \"Calendars.Read\" \n  }\n]<\/pre>\n<p>You can use the following webApiPermissionRequests&#8211; but feel free to use what works for you, and make sure to only ask for the permissions you really need:<\/li>\n<\/ol>\n<pre class=\"lang: decode:true\">\"webApiPermissionRequests\": [\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"User.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"User.Read.All\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"User.ReadBasic.All\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"People.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Calendars.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Contacts.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Group.Read.All\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Group.ReadWrite.All\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Tasks.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Tasks.ReadWrite\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Presence.Read\"\n},\n{\n\"resource\": \"Microsoft Graph\",\n\"scope\": \"Presence.Read.All\"\n}\n]<\/pre>\n<ol start=\"6\">\n<li>Next, build the solution by using the following command lines:\n<span class=\"lang: decode:true crayon-inline \">gulp build<\/span>\n<span class=\"lang: decode:true crayon-inline \">gulp bundle<\/span>\n<span class=\"lang: decode:true crayon-inline \">gulp package-solution<\/span><\/li>\n<li>Once completed, there will be a new <span class=\"lang: decode:true crayon-inline \">.sppkg<\/span>\u00a0 file in the <span class=\"lang: decode:true crayon-inline \">sharepoint\/solution<\/span><\/li>\n<li>Upload the <span class=\"lang: decode:true crayon-inline \">.sppkg<\/span>\u00a0 file to your SharePoint Online\u2019s app catalog, in the <strong>Apps for SharePoint <\/strong><\/li>\n<\/ol>\n<p>You\u2019ll be prompted whether you trust the solution. Make sure to review the permission and select <strong>Deploy<\/strong>.\n<img decoding=\"async\" class=\"alignleft wp-image-4780\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G4-1024x865.png\" alt=\"Pop up display in SharePoint for permission review\" width=\"650\" height=\"549\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G4-1024x865.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G4-300x253.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G4-768x649.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G4.png 1314w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>The dialog box tells you to \u201cPlease go to the API Management Page to approve the pending permissions\u201d. That\u2019s what we\u2019re going to do next.<\/p>\n<h3>Step 7: Approve Pending Permissions<\/h3>\n<p>When you deployed the solution package to the app catalog, it automatically created an API access request for each of the Microsoft Graph API permission you defined in the <span class=\"lang: decode:true crayon-inline \">package-solution.json<\/span>\u00a0.<\/p>\n<p>Before you can go any further, you need to approve the pending permissions. To do so, follow these steps:<\/p>\n<ol>\n<li>Go to your <strong>SharePoint Admin Center <\/strong>(https:\/\/[yourtenant]-admin.sharepoint.com)<\/li>\n<li>From the left navigation, select <strong>Advanced <\/strong>then <strong>API access<\/strong>.<\/li>\n<\/ol>\n<p>3. You should see a number of <strong>Pending requests<\/strong>. They should match the permissions you declared\u00a0 earlier.\n<img decoding=\"async\" class=\"alignleft wp-image-4781\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G5-1024x484.png\" alt=\"A list of pending requests for Microsoft Graph permissions in SharePoint admin center\" width=\"650\" height=\"307\" \/><\/p>\n<p>4. Select a pending request and select <strong>Approve<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4782\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G6-1024x494.png\" alt=\"Select a pending request in SharePoint admin center\" width=\"650\" height=\"313\" \/><\/p>\n<p>5. In the <strong>Approve access <\/strong>panel that will appear, select <strong>Approve<\/strong>.<\/p>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4783\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G7-1024x483.png\" alt=\"Approve access panel view in SharePoint admin center\" width=\"650\" height=\"307\" \/><\/p>\n<ol>\n<li>Repeat each pending request until they\u2019re all approved.<\/li>\n<\/ol>\n<p>Now we\u2019re ready to test the application.<\/p>\n<h3>Step 8: Test Web Part<\/h3>\n<p>Typically, when you test your SPFx solutions, you use the <strong>local workbench<\/strong> \u2013 which runs locally on your workstation. It isn\u2019t authenticated, so your MGT components won\u2019t work.<\/p>\n<p>In order to test SPFx solutions that use the MGT, you need to use the <strong>hosted workbench<\/strong> because it runs on your tenant and will use your authenticated context. You\u2019ll find the hosted workbench on your tenant at <a href=\"https:\/\/[yourtenant].sharepoint.com\/_layouts\/15\/workbench.aspx\"><strong>https:\/\/[yourtenant].sharepoint.com\/_layouts\/15\/workbench.aspx<\/strong><\/a>. You can test your project on your hosted workbench by following these steps:<\/p>\n<ol>\n<li>Open <span class=\"lang: decode:true crayon-inline \">config\\serve.json<\/span>\u00a0 using your code editor.<\/li>\n<li>Look for a line that starts with &#8220;initialPage&#8221;: and enter the url to your hosted workbench, as follows:\n<span class=\"lang: decode:true crayon-inline \">&#8220;initialPage&#8221;: &#8220;https:\/\/[yourtenant].sharepoint.com\/_layouts\/15\/workbench.aspx&#8221;,<\/span><\/li>\n<li>Once your file is saved, go to your command prompt and launch your web part by typing the following command:\n<span class=\"lang: decode:true crayon-inline \">gulp serve<\/span><\/li>\n<li>It should launch your browser and open your hosted workbench.<\/li>\n<li>Add your new web part to the page.<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4784\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8-1024x516.png\" alt=\"Add mgt component web part in SharePoint\" width=\"650\" height=\"328\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8-1024x516.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8-300x151.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8-768x387.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8-1536x774.png 1536w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G8.png 2045w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>6. If everything went well, you should see your MGT components in action!<\/p>\n<p><img decoding=\"async\" class=\"alignleft wp-image-4785\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G9-1024x337.png\" alt=\"View of mgt component in SharePoint\" width=\"650\" height=\"214\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G9-1024x337.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G9-300x99.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G9-768x253.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2020\/06\/G9-1536x506.png 1536w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>7. As long as your <span class=\"lang: decode:true crayon-inline \">gulp serve<\/span>\u00a0 is running, you can continue editing your code and refreshing your browser to see your changes.<\/p>\n<h2>Conclusion<\/h2>\n<p>It took a few steps to build a SharePoint Framework solution using the Microsoft Graph Toolkit SharePoint provider, but we did it!<\/p>\n<p>When you\u2019re done building your web part, you\u2019ll want to package it for production (using <span class=\"lang: decode:true crayon-inline \">gulp bundle \u2013ship<\/span>\u00a0 and <span class=\"lang: decode:true crayon-inline \">gulp package-solution \u2013ship<\/span>\u00a0) and re-deploy it to your app catalog, but you won\u2019t have to re-approve the API requests.<\/p>\n<p>Hopefully we were able to demonstrate how, by using the SharePoint provider, you can build SharePoint solutions using the Microsoft Graph Toolkit just as you would in a regular HTML app. That\u2019s the power of the Microsoft Graph Toolkit!<\/p>\n<p>You can find the source code for this sample in the <a href=\"https:\/\/github.com\/microsoftgraph\/mgtLap-TryItOut\/tree\/master\/09%20-%20SharePoint%20Provider\/helloworld-mgt\">mgtLap repository<\/a>. For simplicity, we only built a no-framework SPFx web part. If you\u2019d prefer to use React for your web parts, take a look the <a href=\"https:\/\/github.com\/microsoftgraph\/microsoft-graph-toolkit\/tree\/master\/samples\/sp-webpart\">sample in the Microsoft Graph Toolkit repository<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Lap around Microsoft Graph Toolkit Day 9 &#8211; in this blog we\u2019ll show you how you can apply what you\u2019ve learned so far in your own SPFx solutions.<\/p>\n","protected":false},"author":69076,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[34],"class_list":["post-4776","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-microsoft-graph-toolkit"],"acf":[],"blog_post_summary":"<p>A Lap around Microsoft Graph Toolkit Day 9 &#8211; in this blog we\u2019ll show you how you can apply what you\u2019ve learned so far in your own SPFx solutions.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69076"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=4776"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4776\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=4776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=4776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=4776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}