KDP Node SDK
This Node SDK allows you to use KDP as an authentication mechanism for your application or API.
Pre requisites
You'll need a few things to get started, firstly you'll have to create a new app on the KDP dev site, go to the URL below and create your app..
http://dev.researchplatform.tnsglobal.com/#/RegisterApp
Make sure you add the following for Url and Redirect URL, then you will be taken to your App Management page.
URL: http://localhost:8080/ Redirect URL: http://localhost:8080/TokenHandler
And go!
Initialise a new Node project, follow the onscreen instructions.
npm init
Install the kdp package and the express package
npm install kdp --savenpm install express --save
Then create an index.js file and code add the following code, remember to replace the APP ID and APP SECRET from your App Management pages on the KDP site.
// require the needed express and kdp modulesvar express = ;var kdpMod = ; // set up your KDP config, you can grab these details from app management on the KDP site.var kdpConfig = https: false url: "dev.researchplatform.tnsglobal.com" app_id: "---INSERT YOUR APP ID HERE---" app_secret: "---INSERT YOUR APP SECRET HERE---" app_name: "My Node app" // create a new instance of the KDP module helpersvar kdp = ; // set up your express appapp = ; // bind KDP in to the app, this will do all of the redirection and authentication require// it basically creates the cookies we need to identify a userkdp; // Ok, lets set up an endpoint, this will just be route on your express app with some KDP code inside//// Requirements:// The user must be authenticated// The user must have BasicAccess permission//app; // finally start up the serverapp;
Finally, try out the magic!
node indexjs
What next?
Try the Node.js KDP API Template here...