Skip to content

Instantly share code, notes, and snippets.

@allenmichael
Created September 15, 2017 09:40
Show Gist options
  • Select an option

  • Save allenmichael/7f4e613d266a9549749d0ce53963447a to your computer and use it in GitHub Desktop.

Select an option

Save allenmichael/7f4e613d266a9549749d0ce53963447a to your computer and use it in GitHub Desktop.
Authenticate to Box with a Service Account and create a new App User
'use strict';
let BoxService = require('./boxClientService');
let Box = require('box-node-sdk');
const fs = require('fs');
let configFile = fs.readFileSync('config.json');
configFile = JSON.parse(configFile);
let BoxInstance = Box.getPreconfiguredInstance(configFile);
let serviceAccount = BoxInstance.getAppAuthClient('enterprise');
serviceAccount.enterprise.addAppUser('test appuser', null, function (err, user) {
if (err) {
console.log(err);
return;
}
console.log(user);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment