Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including passport-sharepoint-addin with all npm packages installed. Try it out:

var passportSharepointAddin = require("passport-sharepoint-addin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

passport-sharepoint-addin v0.1.0

Passport.js authentication middleware for SharePoint add-in

Passport.js authentication middleware for SharePoint add-in

Passport.js authentication strategy for SharePoint Online and SharePoint on-premise performing authentication via ACS.

This module allows you to perform SharePoint add-in authentication for your Node.js Express web application. Can be also integrated into other connect-based frameworks.

Install

npm install passport-sharepoint-addin

Usage

For detailed in-depth tutorial and configuration workflow please visit sample here - Express SharePoint add-in sample.

Basic setup

passport.use(new SharePointAddinStrategy({clientId: '', clientSecret: ''}, 'https://site.com/auth/sharepoint/callback', (profile: ISharePointProfile) => {
        return User.findOne({ 'sharepoint.loginName': profile.loginName })
            .then(user => {
                if (user) {
                    return user;
                }

                const newUser = new User();
                newUser.sharepoint.email = profile.email;
                newUser.sharepoint.loginName = profile.loginName;
                newUser.sharepoint.displayName = profile.displayName;
                return newUser.save();
            });
    }));
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free