Azure Active Directory Step-By-Step Integration with Node.JS

Frank Chung
DeepQ Research Engineering Blog
2 min readFeb 24, 2018

The tutorial provided by microsoft is out-dated and unclear, here I provide my experience for running the sample on github.

  1. Sign in to the Azure Portal.
  2. Click on Azure Active Directory on left menu.
  3. Click on App registrations on sub menu.
  4. Click on New application registration.
  5. Create your app with name and home page http://localhost:3000/

6. Click on Settings -> Reply URLs

7. Add a replay URL as http://localhost:3000/auth/openid/return

8. Click on Settings -> Keys, and add a password

9. Save the password and copy the hashed password value to clipboard

10. Clone the azure official sample on github, and make sure you are in the master branch.

cd WebApp-OpenIDConnect-NodeJS
npm install

11. Edit the config.js, we use common tenant as example

// common tenant URL
identityMetadata: 'https://login.microsoftonline.com/common/.well-known/openid-configuration'
// Application id
clientID: '9ab7110c-d854-44f6-8dd4-4a56af1d371c',
// must same with reply URLs
redirectUrl: 'http://localhost:3000/auth/openid/return',
// the password on clipboard
clientSecret: 'TguHIDKjisJIgHJWSaqgW5+LPotoTJVkR2DGmdEjrbE=',
// set to false if use common tenant URL
validateIssuer: false,
// use default session store instead of mongo db.
exports.useMongoDBSessionStore = false;

12. Run the server

node app.js

13. Open http://localhost:3000/ in browser and have a luck

--

--