Thursday 13 April 2017

SOAP client authentication using node

I am trying to authenticate to a SOAP API via a node client.

Error:

This request requires HTTP authentication (No user credentials found).

Code:

const soap    = require('soap');

const url = 'https://api.fakecompany.com/soap?wsdl';
const auth = "Basic " + new Buffer("fakeuser" + ":" + "fakepassword").toString("base64")

soap.createClient(url, {wsdl_headers: {Authorization: auth} }, function(err, client) {

    if (err) {
      console.log(err);
    }

    if (client) {
      client.getMyPermissions(function(err, result) {
          console.log(result.body);
      });
    }

});



via CiscoKidx

No comments:

Post a Comment