O365 and OneDrive with ADAL, Microsoft Graph API & Office Add-In

Published May 01 2019 04:06 PM 380 Views
Microsoft

First published on TECHNET on Oct 16, 2017
This post is a contribution from Manish Joshi, an engineer with the SharePoint Developer Support team

This blog demonstrates creating an Office add-in and retrieving data from SharePoint Online and One Drive within the add-in. The add-in uses ADAL.js for authentication and retrieving access token. In addition it uses Graph API and SharePoint REST API for accessing data from One Drive and SharePoint Online.
Create new Azure Web app

 

    • Click on App Services

 

    • Click  Add-> Web Apps-> Click Create

 

    • Set a unique App name. Example : o365officeaddin.

 

    • Set Resource Group: Either Create New or Select Existing. Click on Create.

 

    • Browse back to app services to seethe newly created web app.

 

    • Click on the newly created web app ->  Click Get publish profile from the menu in right section.

 

    • Click Save File-> The file will be saved in "C:\Users\<<username>>\Downloads" folder with name o365officeaddin.PublishSettings




Register new Azure App

    • Click on Azure Active Directory-> Click Switch directory

 

    • Select your corporate Directory. In my case it’s Contoso.

 

    • Click App registrations-> Click New application registration

 

    • Enter Name: o365officeaddin

 

    • Select Application type: Web App/ API

 

 

    • Click on Azure Active Directory-> Click App registrations-> Click o365officeadin-> Click Properties

 

 

 

    • Make a note of "Application Id" we will use this later in javascript code for the clientId.

 

    • Click Manifest-> Update value for “oauth2AllowImplicitFlow” to "true". Click Save




Grant Permissions to the new Azure app

    • Click Required permissions-> Click Windows Azure Active Directory

 

    • Under "Delegated Permissions" check following:

        • Sign in and read user profile

        • Read and write directory data

        • Access the directory as the signed-in user
          Click Save


 

    • Click Add-> Select an API

 

    • Click Microsoft Graph-> Click Select

 

    • Under "Delegated Permissions" check following:

        • Sign in and read user profile

        • Read and write directory data

        • Access the directory as the signed-in user

        • Have full access to user files

        • Have full access to all files user can access
          Click Save


 

    • Click Select-> Click Done

 

    • Click Add-> Select an API

 

    • Click Office 365 SharePoint Online-> Click Select

 

    • Under "Delegated Permissions" check following:

        • Read and write user files

        • Run search queries as a user

        • Read and write managed metadata


 

    • Click Microsoft Graph->Click Grant Permissions-> Click Yes

 

    • Click Select-> Click Done




Create new Word Add-in Project

    • Launch Visual Studio 2015-> Click New Project

 

    • Under Office/SharePoint-> Select Web Add-ins-> Select Word Add-in

 

    • Give Name: o365officeaddin-> Click OK

 

    • In Home.html Insert following code just after <body>. In the below code update the sharePointTenantName with your tenant name and the clientId with the Application Id we copied in the earlier steps.


      <div id="content-header">
      <strong><span class='app-user navbar-text'></span></strong>

      <div class="search-area">
      <input id="tb-search-input" type="text" value="search query" />
      <input id="btn-search" type="button" value="Search" /><input id="btn-onedrive" type="button" value="OneDrive" />
      <div id="search-results">
      </div>
      </div>
      </div>

      <script type="text/javascript">
      (function (window, $) {
      // Azure AD App Manifest - Set 'oauth2AllowImplicitFlow' property to 'true' ("oauth2AllowImplicitFlow": true)
      // https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-manifes...
      var sharePointTenantName = '<<yourO365tenant>>';
      var config = window.config = {
      tenant: sharePointTenantName + '.onmicrosoft.com',
      clientId: 'feea2058-6ff6-4847-9dfe-854400becd24',
      postLogoutRedirectUri: window.location.origin,
      endpoints: {
      graphApiUrl: 'https://graph.microsoft.com',
      sharePointUrl: 'https://' + sharePointTenantName + '.sharepoint.com'
      },
      cacheLocation: 'localStorage'
      };

      var authContext = new AuthenticationContext(config);
      var $userDisplay = $(".app-user");
      var $searchInput = $('#tb-search-input');
      var $searchButton = $('#btn-search');
      var $searchResultsDiv = $('#search-results');
      var $onedriveButton = $('#btn-onedrive');

      var isCallback = authContext.isCallback(window.location.hash);
      authContext.handleWindowCallback();

      // Check Login Status, Update UI
      var user = authContext.getCachedUser();
      if (user) {
      $userDisplay.html(user.userName);
      $userDisplay.show();

      $searchButton.click(function () {
      var searchText = $searchInput.val();
      $searchResultsDiv.empty();

      if (searchText.length > 0) {
      search(searchText);
      }
      });
      $onedriveButton.click(function () {
      onedrive();
      });
      }
      else {
      authContext.login();

      $userDisplay.empty();
      $userDisplay.hide();
      $searchInput.hide();
      $searchButton.hide();
      }

      function search(searchText) {
      var searchEndpoint = 'https://' + sharePointTenantName + '.sharepoint.com/_api/search/query?querytext=\'' + searchText + '\'';

      authContext.acquireToken(config.endpoints.sharePointUrl, function (error, token) {
      if (error || !token) {
      console.log(error);
      }
      else {
      $.ajax({
      beforeSend: function (request) {
      request.setRequestHeader("Accept", "application/json");
      },
      type: "GET",
      url: searchEndpoint,
      dataType: "json",
      headers: {
      'Authorization': 'Bearer ' + token,
      }
      }).done(function (response) {
      $searchResultsDiv.html(JSON.stringify(response));

      }).fail(function (response) {
      console.log(response.responseText);
      });
      }
      });
      }
      function onedrive() {
      var onedriveEndpoint = "https://graph.microsoft.com/v1.0/me";

      authContext.acquireToken(config.endpoints.graphApiUrl, function (error, token) {
      if (error || !token) {
      console.log(error);
      }
      else {
      $.ajax({
      beforeSend: function (request) {
      request.setRequestHeader("Accept", "application/json");
      },
      type: "GET",
      url: onedriveEndpoint,
      dataType: "json",
      headers: {
      'Authorization': 'Bearer ' + token,
      }
      }).done(function (response) {
      $searchResultsDiv.html(JSON.stringify(response));

      }).fail(function (response) {
      console.log(response.responseText);
      });
      }
      });
      }
      })(window, window.jQuery);

      </script>





    • Add the below script reference in the head section


      <script src="//secure.aadcdn.microsoftonline-p.com/lib/1.0.0/js/adal.min.js"></script>




Publish and install the Add-in

    • Click Build-> Build Solution

 

    • Right click o365officeaddin project-> Select Publish

 

    • Current profile: Click <New…>

 

    • Browse to path where you have saved the o365officeaddin.PublishSettings file. Click Finish

 

    • Click Deploy your web project-> Click Publish

 

    • Once publish has succeeded Click Package the add-in

 

 

    • Next it will generate the o365officeaddinManifest.xml file. This file will be generated in the folder "bin\Debug\app.publish\OfficeAppManifests".

 

    • Browse to your Office 365 site

 

    • Browse to a document library

 

    • Edit an existing Word Document or create a new one -> Click Open-> Click Word Online

 

    • Click INSERT-> Click Office Add-ins

 

    • Click Upload My Add-In

 

    • Click Browse-> Browse to o365officeaddinManifest.xml location-> Click Upload

 

    • Click "Show Taskpane" to see your Add-in UI

 

    • Enter a search text in the search query box-> Click Search-> You will see JSON for the search results returned.





    • Click OneDrive button to see it get details of the current user from OneDrive using graph REST endpoint.




Installing the Add-in to App Catalog
We can make the add-in available globally instead of having to upload the manifest.xml file everytime. When we packaged the add-in in the earlier step the .app file for the add-in was also generated at the path "bin\Debug\app.publish".  Follow the below steps to make this add-in available globally across your tenant without requiring to upload the manifest.xml file every time.

    • Browse to the app catalog site collection in your tenant

 

    • Go to Apps for SharePoint

 

    • Upload the office365addin.app file from the location "bin\Debug\app.publish"

 

    • Install the add-in in the app catalog site collection by going to Site Actions -> Add an App

 

    • One the app is installed Browse to document library in any site collection in your tenant and add or edit a word document in browser.

 

    • Click on "Insert" -> "Office Add-ins" command in the ribbon . You should be able to see your office add-in under My Organization tab

 

%3CLINGO-SUB%20id%3D%22lingo-sub-510016%22%20slang%3D%22en-US%22%3EO365%20and%20OneDrive%20with%20ADAL%2C%20Microsoft%20Graph%20API%20%26amp%3B%20Office%20Add-In%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-510016%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3EFirst%20published%20on%20TECHNET%20on%20Oct%2016%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3EThis%20post%20is%20a%20contribution%20from%20Manish%20Joshi%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%20%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20blog%20demonstrates%20creating%20an%20Office%20add-in%20and%20retrieving%20data%20from%20SharePoint%20Online%20and%20One%20Drive%20within%20the%20add-in.%20The%20add-in%20uses%20ADAL.js%20for%20authentication%20and%20retrieving%26nbsp%3Baccess%20token.%20In%20addition%20it%20uses%20Graph%20API%20and%20SharePoint%20REST%20API%20for%20accessing%20data%20from%20One%20Drive%20and%20SharePoint%20Online.%20%3CBR%20%2F%3ECreate%20new%20Azure%20Web%20app%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20to%20Azure%20Portal%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20https%3A%2F%2Fportal.azure.com%20%3C%2FA%3E%20.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20App%20Services%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%26nbsp%3B%20Add-%26gt%3B%20Web%20Apps-%26gt%3B%20Click%20Create%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESet%20a%20unique%20App%20name.%20Example%20%3A%20o365officeaddin.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESet%20Resource%20Group%3A%20Either%20Create%20New%20or%20Select%20Existing.%20Click%20on%20Create.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20back%20to%20app%20services%20to%20seethe%20newly%20created%20web%20app.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20the%20newly%20created%20web%20app%20-%26gt%3B%26nbsp%3B%20Click%20Get%20publish%20profile%20from%20the%20menu%20in%20right%20section.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Save%20File-%26gt%3B%20The%20file%20will%20be%20saved%20in%20%22C%3A%5CUsers%5C%26lt%3B%3CUSERNAME%3E%26gt%3B%5CDownloads%22%20folder%20with%20name%20o365officeaddin.PublishSettings%3C%2FUSERNAME%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ERegister%20new%20Azure%20App%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20Azure%20Active%20Directory-%26gt%3B%20Click%20Switch%20directory%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20your%20corporate%20Directory.%20In%20my%20case%20it%E2%80%99s%20Contoso.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20App%20registrations-%26gt%3B%20Click%20New%20application%20registration%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEnter%26nbsp%3BName%3A%20o365officeaddin%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESelect%26nbsp%3BApplication%20type%3A%20Web%20App%2F%20API%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEnter%26nbsp%3BSign-on%20URL%20as%20the%20url%20of%20the%20newly%20created%20azure%20web%20app.%20Example%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fo365officeaddin.azurewebsites.net%2FHome.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fo365officeaddin.azurewebsites.net%2FHome.html%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20Azure%20Active%20Directory-%26gt%3B%20Click%20App%20registrations-%26gt%3B%20Click%20o365officeadin-%26gt%3B%20Click%20Properties%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESet%20App%20ID%20URI%3A%20%3CA%20href%3D%22https%3A%2F%2FyourO365tenant.onmicrosoft.com%2Fo365officeaddin%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2FyourO365tenant.onmicrosoft.com%2Fo365officeaddin%3C%2FA%3E.%20Click%20Save.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEdit%20the%20reply%20Urls%20and%20add%20the%20url%20of%20your%20web%20app%20with%20an%20additional%20query%20string%20%E2%80%9C%3Fet%3D%E2%80%9D%20%3CBR%20%2F%3EExample%20-%3A%20%3CA%20href%3D%22https%3A%2F%2FyourO365tenant.onmicrosoft.com%2Fo365officeaddin%2FHome.html%3Fet%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2FyourO365tenant.onmicrosoft.com%2Fo365officeaddin%2FHome.html%3Fet%3D%3C%2FA%3E%20%3CBR%20%2F%3ENote%20the%20reply%20urls%20are%20cases%20sensitive%20and%20you%20may%20get%20an%20error%20if%20there%20is%20a%20case%20mismatch.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EMake%20a%20note%20of%20%22Application%20Id%22%20we%20will%20use%20this%20later%20in%20javascript%20code%20for%20the%20clientId.%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20551px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111607i3F9109554577F439%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Manifest-%26gt%3B%26nbsp%3BUpdate%20value%20for%26nbsp%3B%E2%80%9Coauth2AllowImplicitFlow%E2%80%9D%20to%20%22true%22.%20Click%20Save%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EGrant%20Permissions%20to%20the%20new%20Azure%20app%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Required%20permissions-%26gt%3B%20Click%20Windows%20Azure%20Active%20Directory%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EUnder%20%22Delegated%26nbsp%3BPermissions%22%20check%20following%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESign%20in%20and%20read%20user%20profile%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERead%20and%20write%20directory%20data%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EAccess%20the%20directory%20as%20the%20signed-in%20user%20%3CBR%20%2F%3EClick%20Save%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Add-%26gt%3B%20Select%20an%20API%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Microsoft%20Graph-%26gt%3B%20Click%20Select%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EUnder%26nbsp%3B%22Delegated%26nbsp%3BPermissions%22%20check%20following%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESign%20in%20and%20read%20user%20profile%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERead%20and%20write%20directory%20data%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EAccess%20the%20directory%20as%20the%20signed-in%20user%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EHave%20full%20access%20to%20user%20files%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EHave%20full%20access%20to%20all%20files%20user%20can%20access%20%3CBR%20%2F%3EClick%20Save%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Select-%26gt%3B%20Click%20Done%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Add-%26gt%3B%20Select%20an%20API%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Office%20365%20SharePoint%20Online-%26gt%3B%20Click%20Select%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EUnder%26nbsp%3B%22Delegated%26nbsp%3BPermissions%22%20check%20following%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERead%20and%20write%20user%20files%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERun%20search%20queries%20as%20a%20user%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERead%20and%20write%20managed%20metadata%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Microsoft%20Graph-%26gt%3BClick%20Grant%20Permissions-%26gt%3B%20Click%20Yes%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Select-%26gt%3B%20Click%20Done%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ECreate%20new%20Word%20Add-in%20Project%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ELaunch%20Visual%20Studio%202015-%26gt%3B%20Click%20New%20Project%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EUnder%20Office%2FSharePoint-%26gt%3B%20Select%20Web%20Add-ins-%26gt%3B%20Select%20Word%20Add-in%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EGive%20Name%3A%20o365officeaddin-%26gt%3B%20Click%20OK%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EIn%20Home.html%20Insert%20following%20code%20just%20after%20.%20In%20the%20below%20code%20update%20the%20sharePointTenantName%26nbsp%3Bwith%20your%20tenant%20name%26nbsp%3Band%20the%20clientId%20with%20the%20Application%20Id%20we%20copied%20in%20the%20earlier%20steps.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDIV%3E%3CBR%20%2F%3E%3CDIV%20id%3D%22%26quot%3Bcontent-header%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CSTRONG%3E%3CSPAN%20class%3D%22'app-user%22%20navbar-text%3D%22%22%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDIV%20class%3D%22%26quot%3Bsearch-area%26quot%3B%22%3E%20%3CBR%20%2F%3E%3CINPUT%20id%3D%22%26quot%3Btb-search-input%26quot%3B%22%20type%3D%22%26quot%3Btext%26quot%3B%22%20value%3D%22%26quot%3Bsearch%22%20query%3D%22%22%20%2F%3E%20%3CBR%20%2F%3E%3CINPUT%20id%3D%22%26quot%3Bbtn-search%26quot%3B%22%20type%3D%22%26quot%3Bbutton%26quot%3B%22%20value%3D%22%26quot%3BSearch%26quot%3B%22%20%2F%3E%3CINPUT%20id%3D%22%26quot%3Bbtn-onedrive%26quot%3B%22%20type%3D%22%26quot%3Bbutton%26quot%3B%22%20value%3D%22%26quot%3BOneDrive%26quot%3B%22%20%2F%3E%20%3CBR%20%2F%3E%3CDIV%20id%3D%22%26quot%3Bsearch-results%26quot%3B%22%3E%20%3CBR%20%2F%3E%3C%2FDIV%3E%20%3CBR%20%2F%3E%3C%2FDIV%3E%20%3CBR%20%2F%3E%3C%2FDIV%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSCRIPT%20type%3D%22%26quot%3Btext%2Fjavascript%26quot%3B%22%3E%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B(function%20(window%2C%20%24)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%2F%2F%20Azure%20AD%20App%20Manifest%20-%20Set%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3Boauth2AllowImplicitFlow%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20property%20to%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3Btrue%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3Boauth2AllowImplicitFlow%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%3A%20true)%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%2F%2F%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-application-manifest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%22%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bhttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fdevelop%2Factive-directory-application-manifest%26amp%3Bamp%3Bamp%3Bamp%3Blt%3B%2FA%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20sharePointTenantName%20%3D%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3ByourO365tenant%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20config%20%3D%20window.config%20%3D%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Btenant%3A%20sharePointTenantName%20%2B%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B.onmicrosoft.com%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BclientId%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3Bfeea2058-6ff6-4847-9dfe-854400becd24%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BpostLogoutRedirectUri%3A%20window.location.origin%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bendpoints%3A%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BgraphApiUrl%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%22%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bhttps%3A%2F%2Fgraph.microsoft.com%26amp%3Bamp%3Bamp%3Bamp%3Blt%3B%2FA%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BsharePointUrl%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3Bhttps%3A%2F%2F%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%2B%20sharePointTenantName%20%2B%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B.sharepoint.com%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BcacheLocation%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3BlocalStorage%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20authContext%20%3D%20new%20AuthenticationContext(config)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20%24userDisplay%20%3D%20%24(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B.app-user%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20%24searchInput%20%3D%20%24(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%23tb-search-input%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20%24searchButton%20%3D%20%24(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%23btn-search%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20%24searchResultsDiv%20%3D%20%24(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%23search-results%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20%24onedriveButton%20%3D%20%24(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%23btn-onedrive%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20isCallback%20%3D%20authContext.isCallback(window.location.hash)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BauthContext.handleWindowCallback()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%2F%2F%20Check%20Login%20Status%2C%20Update%20UI%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20user%20%3D%20authContext.getCachedUser()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bif%20(user)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24userDisplay.html(user.userName)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24userDisplay.show()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchButton.click(function%20()%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20searchText%20%3D%20%24searchInput.val()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchResultsDiv.empty()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bif%20(searchText.length%20%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%200)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bsearch(searchText)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24onedriveButton.click(function%20()%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bonedrive()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Belse%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BauthContext.login()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24userDisplay.empty()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24userDisplay.hide()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchInput.hide()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchButton.hide()%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bfunction%20search(searchText)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20searchEndpoint%20%3D%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3Bhttps%3A%2F%2F%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%2B%20sharePointTenantName%20%2B%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B.sharepoint.com%2F_api%2Fsearch%2Fquery%3Fquerytext%3D%5C%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%2B%20searchText%20%2B%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%5C%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BauthContext.acquireToken(config.endpoints.sharePointUrl%2C%20function%20(error%2C%20token)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bif%20(error%20%7C%7C%20!token)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bconsole.log(error)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Belse%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24.ajax(%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BbeforeSend%3A%20function%20(request)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Brequest.setRequestHeader(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3BAccept%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3Bapplication%2Fjson%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Btype%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3BGET%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Burl%3A%20searchEndpoint%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BdataType%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3Bjson%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bheaders%3A%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3BAuthorization%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3BBearer%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%2B%20token%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D).done(function%20(response)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchResultsDiv.html(JSON.stringify(response))%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D).fail(function%20(response)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bconsole.log(response.responseText)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bfunction%20onedrive()%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bvar%20onedriveEndpoint%20%3D%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BA%20href%3D%22https%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%22%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bhttps%3A%2F%2Fgraph.microsoft.com%2Fv1.0%2Fme%26amp%3Bamp%3Bamp%3Bamp%3Blt%3B%2FA%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BauthContext.acquireToken(config.endpoints.graphApiUrl%2C%20function%20(error%2C%20token)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bif%20(error%20%7C%7C%20!token)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bconsole.log(error)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Belse%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24.ajax(%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BbeforeSend%3A%20function%20(request)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Brequest.setRequestHeader(%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3BAccept%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3Bapplication%2Fjson%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Btype%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3BGET%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Burl%3A%20onedriveEndpoint%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3BdataType%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3Bjson%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3Bquot%3B%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bheaders%3A%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3BAuthorization%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%3A%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3BBearer%20%26amp%3Bamp%3Bamp%3Bamp%3Bamp%3B%2339%3B%20%2B%20token%2C%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D).done(function%20(response)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%24searchResultsDiv.html(JSON.stringify(response))%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D).fail(function%20(response)%20%7B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3Bconsole.log(response.responseText)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%7D)(window%2C%20window.jQuery)%3B%20%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%26amp%3Bamp%3Bamp%3Bamp%3Blt%3BBR%20%2F%26amp%3Bamp%3Bamp%3Bamp%3Bgt%3B%3C%2FSCRIPT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EAdd%20the%20below%20script%20reference%20in%20the%20head%20section%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDIV%3E%3CBR%20%2F%3E%3CSCRIPT%20src%3D%22%26quot%3B%2F%2Fsecure.aadcdn.microsoftonline-p.com%2Flib%2F1.0.0%2Fjs%2Fadal.min.js%26quot%3B%22%3E%3C%2FSCRIPT%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FDIV%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EPublish%20and%20install%20the%20Add-in%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Build-%26gt%3B%20Build%20Solution%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ERight%20click%20o365officeaddin%20project-%26gt%3B%20Select%20Publish%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ECurrent%20profile%3A%20Click%20%3CNEW%3E%3C%2FNEW%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20to%20path%20where%20you%20have%20saved%20the%20o365officeaddin.PublishSettings%20file.%20Click%20Finish%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Deploy%20your%20web%20project-%26gt%3B%20Click%20Publish%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EOnce%20publish%20has%20succeeded%20Click%20Package%20the%20add-in%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EChange%20the%20URL%20to%20the%20url%20of%20the%20azure%20web%20app%20we%20created%20in%20previous%20steps.%20Example%20%3CA%20href%3D%22https%3A%2F%2Fo365officeaddin.azurewebsites.net%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fo365officeaddin.azurewebsites.net%3C%2FA%3E.%20Click%20Finish%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ENext%20it%20will%20generate%20the%20o365officeaddinManifest.xml%20file.%20This%20file%20will%20be%20generated%20in%20the%20folder%20%22bin%5CDebug%5Capp.publish%5COfficeAppManifests%22.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20to%20your%20Office%20365%20site%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20to%20a%20document%20library%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEdit%20an%20existing%20Word%20Document%20or%20create%20a%20new%20one%20-%26gt%3B%20Click%20Open-%26gt%3B%20Click%20Word%20Online%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20INSERT-%26gt%3B%20Click%20Office%20Add-ins%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Upload%20My%20Add-In%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20Browse-%26gt%3B%20Browse%20to%20o365officeaddinManifest.xml%20location-%26gt%3B%20Click%20Upload%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20%22Show%20Taskpane%22%20to%20see%20your%20Add-in%20UI%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEnter%20a%20search%20text%20in%20the%20search%20query%20box-%26gt%3B%20Click%20Search-%26gt%3B%20You%20will%20see%20JSON%20for%20the%20search%20results%20returned.%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20334px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111608i3AAB0770F357122A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20OneDrive%20button%20to%20see%20it%20get%20details%20of%20the%20current%20user%20from%20OneDrive%20using%20graph%20REST%20endpoint.%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20360px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111609iD8A12ADF0B2C8A6A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EInstalling%20the%20Add-in%20to%20App%20Catalog%20%3CBR%20%2F%3EWe%20can%20make%20the%20add-in%20available%20globally%20instead%20of%20having%20to%20upload%20the%20manifest.xml%20file%20everytime.%20When%20we%20packaged%20the%20add-in%20in%20the%20earlier%20step%20the%20.app%20file%20for%20the%20add-in%20was%20also%20generated%20at%20the%20path%20%22bin%5CDebug%5Capp.publish%22.%26nbsp%3B%20Follow%20the%20below%20steps%20to%20make%20this%20add-in%20available%20globally%20across%20your%20tenant%20without%20requiring%20to%20upload%20the%20manifest.xml%20file%20every%20time.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EBrowse%20to%20the%20app%20catalog%20site%20collection%20in%20your%20tenant%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EGo%20to%20Apps%20for%20SharePoint%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EUpload%20the%20office365addin.app%20file%20from%20the%20location%20%22bin%5CDebug%5Capp.publish%22%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EInstall%20the%20add-in%20in%20the%20app%20catalog%20site%20collection%20by%20going%20to%20Site%20Actions%20-%26gt%3B%20Add%20an%20App%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EOne%20the%20app%20is%20installed%20Browse%20to%20document%20library%20in%20any%20site%20collection%20in%20your%20tenant%20and%20add%20or%20edit%20a%20word%20document%26nbsp%3Bin%20browser.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20%22Insert%22%20-%26gt%3B%20%22Office%20Add-ins%22%20command%20in%20the%20ribbon%20.%20You%20should%20be%20able%20to%20see%20your%20office%20add-in%20under%20My%20Organization%20tab%20%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20693px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111610i9396651E1FA56409%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-510016%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Oct%2016%2C%202017%20This%20post%20is%20a%20contribution%20from%20Manish%20Joshi%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20teamThis%20blog%20demonstrates%20creating%20an%20Office%20add-in%20and%20retrieving%20data%20from%20SharePoint%20Online%20and%20One%20Drive%20within%20the%20add-in.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-510016%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Sep 01 2020 03:42 PM
Updated by: