page_type | products | languages | extensions | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
|
- Introduction
- Prerequisites
- Register the application
- Build and run the sample
- Questions and comments
- Contributing
- Additional resources
This sample shows how to connect an Angular 4.0 app to a Microsoft work or school (Azure Active Directory) using the Microsoft Graph API with the Microsoft Graph JavaScript SDK to get information about the signed-in user and upload that information to an Excel file stored in OneDrive.
Once you authenticate and authorize the application, it gets the signed-in user's name and email address.
When you click the Write to Excel button, the application writes the user information to an Excel file stored in the user's root OneDrive folder.
To use this sample, you need the following:
- Node.js. Node is required to run the sample on a development server and to install dependencies.
- Either a Microsoft account or Office 365 for business account
- Upload the demo.xlsx file in the root of this repository to the root folder of your OneDrive account. This file contains an empty table with two columns.
-
Sign into Azure Portal - App Registrations using either your personal or work or school account.
-
Choose New registration.
-
In the Name section, enter a meaningful application name that will be displayed to users of the app
-
In the Supported account types section, select Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)
-
Select Register to create the application.
The application's Overview page shows the properties of your app.
-
Copy the Application (client) Id. This is the unique identifier for your app.
-
In the list of pages for the app, select Authentication.
-
In the Redirect URIs section, choose Web from the Type dropdown and enter http://localhost:3000/ as the Redirect URI.
-
Under Advanced Settings enable the implicit grant flow by checking the Access tokens and ID tokens boxes
-
Choose Save.
-
Using your favorite IDE, open configs.ts in src/.
-
Replace the ENTER_YOUR_CLIENT_ID placeholder value with the application ID of your registered Azure application.
-
In a command prompt, run the following command in the root directory:
npm install
. -
Run
npm start
to start the development server. -
Navigate to http://localhost:3000/ in your web browser.
-
Choose the Sign in with your Microsoft account button.
-
Sign in with your personal or work or school account and grant the requested permissions.
-
Click the Write to Excel button. Verify that the rows have been added to the demo.xslx file that you uploaded to your root OneDrive folder.
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.
We'd love to get your feedback about this sample. 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].
Copyright (c) 2017 Microsoft. All rights reserved.