[ARCHIVED] Microsoft Graph Connect Sample for Node.js
IMPORTANT
This project is being archived and replaced with the Build Node.js Express apps with Microsoft Graph. As part of the archival process, we're closing all open issues and pull requests.
You can continue to use this sample "as-is", but it won't be maintained moving forward. We apologize for any inconvenience.
Table of contents
- Introduction
- Prerequisites
- Register the application
- Build and run the sample
- Questions and comments
- Contributing
- Additional resources
Introduction
This sample shows how to connect a Node.js app to a Microsoft work or school (Azure Active Directory) or personal (Microsoft) account using the Microsoft Graph API to send an email. In addition, the sample uses the Office Fabric UI for styling and formatting the user experience.
Prerequisites
To use the Microsoft Graph Connect Sample for Node.js, you need the following:
-
Node.js version 4 or above.
-
Either a Microsoft account or a work or school account
Register the application
-
Sign into the App Registration Portal using either your personal or work or school account.
-
Choose Add an app.
-
Enter a name for the app, and choose Create application.
The registration page displays, listing the properties of your app.
-
Copy the Application Id. This is the unique identifier for your app.
-
Under Application Secrets, choose Generate New Password. Copy the password from the New password generated dialog.
You'll use the application ID and secret to configure the sample app in the next section.
-
Under Platforms, choose Add Platform.
-
Choose Web.
-
Enter http://localhost:3000/token as the Redirect URI.
-
Choose Save.
Build and run the sample
-
Download or clone the Microsoft Graph Connect Sample for Node.js.
-
Using your favorite IDE or code editor (we love Visual Studio Code), open utils/config.js.
-
Replace the client_id and client_secret placeholder values with the Application Id and Application secret that you copied during app registration.
-
In a command prompt, run the following command in the root directory. This installs the project dependencies.
npm install
- Run the following command to start the development server.
npm start
-
Navigate to
http://localhost:3000
in your web browser. -
Choose the Connect button.
-
Sign in with your personal or work or school account and grant the requested permissions.
-
Optionally edit the recipient's email address, and then choose the Send mail button. When the mail is sent, a Success message is displayed below the button.
Note: To understand the code for calling the Microsoft Graph API in a Node.js app, see Get started with Microsoft Graph in a Node.js app.
Questions and comments
We'd love to get your feedback about the Microsoft Graph Connect Sample for Node.js. You can send your questions and suggestions in the Issues section of this repository.
Questions about Microsoft Graph development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged 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 [email protected] with any additional questions or comments.
Additional resources
Copyright
Copyright (c) 2016 Microsoft. All rights reserved.