Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Latest commit

 

History

History
129 lines (93 loc) · 6.34 KB

README.md

File metadata and controls

129 lines (93 loc) · 6.34 KB

Microsoft Graph Search API Sample for Excel AddIn (Node.js)

Table of contents

Introduction

This sample includes a NodeJS/Express application that demonstrates how to add an AddIn to Excel and trade and IdentityAPI token for a Graph token to make a call to Microsoft Graph Search API endpoint.

Prerequisites

This sample requires the following:

Getting started with the sample

  1. Download or clone this repo.

Configure Azure

Follow the steps in Configuring Azure.

Configure the project

  1. Open Visual Studio code to the ./Sample2.2a/SearchBetaApi folder
  2. Open the server.ts file
  3. Replace the values for the following:
  • {client TenantID} - your Azure AD Tenant ID
  • {client GUID}- the client id from the Configuring Azure steps
  • {client secret} - the client secret from the Configuring Azure steps

NOTE: If you did the Visual Studio sample in Sample 1.0, you can skip to Test the AddIn as all the settings are the same.

Update the AddIn manifest xml

  1. Open the GraphSearchApiExcel.xml file
  2. Scroll to the bottom of the file, in the WebApplicationInfo section, ensure that the clientid matches the client id from the Configuring Azure steps
  3. Save the file

Create a File Share

  1. On your development machine, create a folder called c:\manifests
  2. Right-click the folder, select Properties
  3. Click the Sharing tab
  4. Click Share
  5. Enter your account name, click Share
  6. Close the dialog
  7. Copy the GraphSearchApiExcel.xml file to the new manifests share

Register the AddIn Fileshare with Office

  1. Open Excel, click Blank Workbook
  2. Click File->Options
  3. Select the Trust Center tab
  4. Click the Trust Center Settings button
  5. Select the Trusted Add-in Catalogs tab
  6. In the catalog url, type //localhost/manifests, then click Add catalog
  7. Click OK

Register the AddIn with Excel

  1. In the ribbon, select the Insert tab
  2. Click Get Add-ins
  3. Select SHARED FOLDER, the select the Microsoft Graph Search Add-in
  4. Click Add
  5. Close the AddIn window
  6. Click the Home tab
  7. You should now have a new ribbon item in a group called Search and a button called Graph Search API
  8. Click the button, you should the task pane open with error.

Test the AddIn

  1. Switch back to Visual Studio Code
  2. Click the debug tab, then select Launch Program configuration
  3. Switch back to Excel, click Retry to refresh the application task pane.
  4. Run a search, review the results that are exported to the workbook sheet as a filterable and searchable table

Code of note

  • Remember if you make changes, you must run npm run-script build to rebuild the TypeScript files into their corresponding javascript.
  • The server.ts file contains the endpoint that will trade the identity token for the graph token.

Questions and comments

We'd love to get your feedback about this sample! Please send us your questions and suggestions in the Issues section of this repository.

Your feedback is important to us. Connect with us on Stack Overflow. Tag your questions with [MicrosoftGraph].

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.md.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Additional resources

Copyright

Copyright (c) 2019 Microsoft. All rights reserved.