How to use the soap.BearerSecurity function in soap

To help you get started, weā€™ve selected a few soap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CumberlandGroup / node-ews / lib / auth / bearer.js View on Github external
const BearerAuth = function(config, options) {
  if(typeof config === 'object'
    && _.has(config, 'host')
    && _.has(config, 'username')
    && _.has(config, 'token')
  ) {
    return {
      wsdlOptions: {},
      authProfile: new soap.BearerSecurity(config.token, options),
      getUrl: function(url, filePath) {
        // request options
        let requestOptions = {
          auth: {
            bearer: config.token
          }
        };
        requestOptions = _.merge(requestOptions, _.clone(options));
        requestOptions.url = url;

        return when.promise((resolve, reject) => {
          request(requestOptions, function(err, res, body) {
            if(err) reject(err);
            else if(res.statusCode == 401) reject(new Error('Bearer Auth StatusCode 401: Unauthorized.'));
            else fs.writeFile(filePath, body, function(err) {
              if(err) reject(err);
github oxygenhq / oxygen / ox_modules / module-soap.js View on Github external
module.authBearer = function(token) {
        auth = new soap.BearerSecurity(token);
    };