Skip to content

Proof of concept for accessing O365 APIs from Node.js

License

Notifications You must be signed in to change notification settings

domeetings/old_node-mail

Repository files navigation

Node.js Mail/Calendar Sample

This sample is a proof-of-concept sample that uses the Microsoft Office 365 APIs Client Libraries for Cordova Applications from a pure Node.js server app. The client libraries were designed to be run from Cordova-based client apps, so this solution might not work in all situations.

Tricks used

  • To load in the exchange.js file, which is not a Node module, I used the method described here.
  • The exchange.js file uses the AJAX XMLHttpRequest object for sending requests. To get it working quickly without having to modify exchange.js, I used the node-XMLHttpRequest module.

Required software

Running the sample

It's assumed that you have Node.js installed before starting.

  1. Download or fork the sample project.
  2. Install node-XMLHttpRequest and simple-oauth2 with npm.
  3. Download the Office 365 client libraries from Nuget. Copy exchange.js and utility.js into the .\node-modules\exchange\exchange-lib\ directory.
  4. Register the app in Azure Active Directory. The app should be registered as a web app with a Sign-on URL of "http://localhost:8000", and should be given permission to "Read users' mail" and "Read users' calendars".
  5. Edit the .\authHelper.js file. Copy the client ID for your app obtained during app registration and paste it as the value for the id variable. Copy the key you created during app registration and paste it as the value for the secret variable. Save the file.
  6. Install all required Node.js modules npm install
  7. Start the development server: npm start
  8. Use your browser to go to http://127.0.0.1:8000.
  9. You should now be prompted to connect your Office 365 account. Click the link to do so and login with an Office 365 account.
  10. You should see a table listing the existing events in your Office 365 calendar.
  11. You can view email in the inbox by browsing to http://127.0.0.1:8000/mail.

Copyright

Copyright (c) Microsoft. All rights reserved.


Connect with me on Twitter @JasonJohMSFT

Follow the Exchange Dev Blog

About

Proof of concept for accessing O365 APIs from Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published