This repository contains sample SharePoint add-in built with Node.js. Technologies used:
- Experss.js web framework
- Passport.js authentication with help of passport-sharepoint-addin
- MongoDB and mongoose
- PnP-JS-Core as a module for interacting with SharePoint REST API
- On your SharePoint site open App registration page at
https://company.sharepoint.com/sites/your_site/_layouts/15/appregnew.aspx
and register a new app. Generate ClientId and ClientSecret, use ane Title, for App Domain putlocalhost:44355
, for Redirect URI puthttps://localhost:44355/
- Take a note on generated credentials.
- Open SharePoint project from
sharepoint-addin
folder. - Open
AppManifest.xml
and changeClientId
attribute ofRemoteWebApplication
to your generatedClientId
- Deploy the app using Visual Studio (right click on a project -> Deploy)
- Wait for project to be deployed. Click on "Trust it" in a browser after deployment.
- Open command prompt at
web-app
folder. - Run
npm install
- Run
npm run start
. Wait for a while and you will see the server is started and messageListening on port 44355
. - Open your SharePoint site and click on the app. You will be redirected to the app home page.
When you click on the app in SharePoint, you get redirected to auth/sharepoint/appredirect
. The app extracts host url, creates a hash and stores it in Mongo. The the user is get authenticated. Authentication related data is stored inside session, the user information like login name and email are stored inside Mongo.