Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions sharepoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var buildSamlRequest = function (params) {

var parseXml = function (xml, callback) {
var parser = new xml2js.Parser({
emptyTag: '' // use empty string as value when tag empty
emptyTag: '', // use empty string as value when tag empty
explicitArray: false // array is created only if there is more than one child
});

parser.on('end', function (js) {
Expand Down Expand Up @@ -109,16 +110,17 @@ function requestToken(params, callback) {
res.on('end', function () {

parseXml(xml, function (js) {
var body = js['S:Envelope']['S:Body'];

// check for errors
if (js['S:Body']['S:Fault']) {
var error = js['S:Body']['S:Fault']['S:Detail']['psf:error']['psf:internalerror']['psf:text'];
if (body['S:Fault']) {
var error = body['S:Fault']['S:Detail']['psf:error']['psf:internalerror']['psf:text'];
callback(error);
return;
}

// extract token
var token = js['S:Body']['wst:RequestSecurityTokenResponse']['wst:RequestedSecurityToken']['wsse:BinarySecurityToken']['#'];
var token = body['wst:RequestSecurityTokenResponse']['wst:RequestedSecurityToken']['wsse:BinarySecurityToken']['#'];

// Now we have the token, we need to submit it to SPO
submitToken({
Expand Down Expand Up @@ -401,4 +403,4 @@ SP.List.prototype = {
del: del
};

module.exports = SP;
module.exports = SP;