Registry / security / passport-outlook

passport-outlook

JSON →
library3.0.0jsnpmunverified

Passport strategy for authenticating with Outlook.com (Windows Live) accounts using the Outlook REST API v2 and OAuth 2.0. Current stable version is 3.0.0, which drops support for Node <10. This package authenticates against the official Microsoft v2 endpoints, differentiating it from older modules that target v1 or outdated APIs. The strategy integrates with any Connect/Express-style middleware via Passport. It supports standard OAuth2 flows and Microsoft-specific options like prompt, login_hint, and domain_hint. The profile schema was normalized in v2.0.0 to follow the Passport profile convention, so existing users need to update property access (e.g., profile.DisplayName instead of profile.name).

npm install passport-outlook
INSTALL
IMPORT
SIG · PASSPORT-OUTLOOK
P
passport-outlook
securityjavascriptv3.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (OutlookStrategy constructor)
import OutlookStrategy from 'passport-outlook';
const { OutlookStrategy } = require('passport-outlook');
Default export is the strategy class. Named export does not exist.
OutlookStrategy (CommonJS)
const OutlookStrategy = require('passport-outlook').Strategy;
const outlook = require('passport-outlook'); // no .Strategy property
For CommonJS, the strategy is at `.Strategy` or use default export with `require('passport-outlook').default`.
TypeScript types
import OutlookStrategy from 'passport-outlook'; // types included
Package includes TypeScript type definitions. No separate @types package needed.

Express app using Passport with passport-outlook for OAuth2 login via Outlook REST API v2.

import passport from 'passport'; import OutlookStrategy from 'passport-outlook'; import express from 'express'; const app = express(); passport.use(new OutlookStrategy({ clientID: process.env.OUTLOOK_CLIENT_ID ?? '', clientSecret: process.env.OUTLOOK_CLIENT_SECRET ?? '', callbackURL: 'http://localhost:3000/auth/outlook/callback' }, function(accessToken: string, refreshToken: string, profile: any, done: Function) { // Combine profile info with tokens const user = { outlookId: profile.id, displayName: profile.DisplayName, email: profile.EmailAddress, accessToken }; if (refreshToken) (user as any).refreshToken = refreshToken; return done(null, user); })); app.get('/auth/outlook', passport.authenticate('outlook')); app.get('/auth/outlook/callback', passport.authenticate('outlook', { failureRedirect: '/' }), (req, res) => res.redirect('/')); app.listen(3000);
Debug
Known issues
breakingNode.js >=10 required since v3.0.0
fix
Upgrade Node.js to v10 or later, or stay on v2.x if using older Node.
affects: >=3.0.0
breakingProfile schema changed in v2.0.0 to Passport normalized format. Properties like profile.name → profile.DisplayName, profile.emails[0].value → profile.EmailAddress
fix
Update code to reference new profile field names (e.g., profile.DisplayName, profile.EmailAddress).
affects: >=2.0.0
deprecatedOld property names from v1.x (profile.name, profile.emails) deprecated in v2.0.0; removed in later versions?
fix
Use new property names as documented in v2+ README.
affects: >=2.0.0 <3.0.0
gotchaThe strategy exports default as constructor, not named bindings. CommonJS users must use require('passport-outlook').default or destructure Strategy.
fix
Use import syntax for ESM or const OutlookStrategy = require('passport-outlook').default; for legacy CommonJS.
affects: >=3.0.0
gotchaWhen using passReqToCallback: true, the first parameter becomes req, shifting the callback signature.
fix
Check the verify callback signature: (req, accessToken, refreshToken, profile, done) instead of (accessToken, refreshToken, profile, done).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: OutlookStrategy is not a constructor
Importing the module incorrectly in ES module or CommonJS context (e.g., using named import or wrong destructuring).
fix
Use: import OutlookStrategy from 'passport-outlook'; or const OutlookStrategy = require('passport-outlook').default;
Can't find strategy named 'outlook'
The strategy name is not registered with passport. Missing passport.use() call or name mismatch.
fix
Ensure passport.use(new OutlookStrategy(...)) is called before passport.authenticate('outlook').
no callbackURL provided
The callbackURL option is required but missing or undefined.
fix
Provide a valid callbackURL in the strategy constructor (must match Microsoft App Registration setting).
Cannot read property 'DisplayName' of undefined
Profile property is undefined because the API response changed or v2 schema was not accounted for.
fix
Use profile.id, profile.DisplayName, profile.EmailAddress as per v2+ schema.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
passportrequiredCore middleware for authentication
passport-oauth2requiredOAuth 2.0 authentication framework used internally
Agent activity
16 hits · last 30 days
node
14
Amazon
1
Resources
passport-outlook — npm install passport-outlook · libregistry