How to use the soap.BasicAuthSecurity 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 / basic.js View on Github external
const BasicAuth = function(config, options) {
  if(typeof config === 'object'
    && _.has(config, 'host')
    && _.has(config, 'username')
    && _.has(config, 'password')
  ) {
    return {
      wsdlOptions: {},
      authProfile: new soap.BasicAuthSecurity(config.username, config.password, options),
      getUrl: function(url, filePath) {
        // request options
        let requestOptions = { 'auth': { 'user': config.username, 'pass': config.password, 'sendImmediately': false } };
        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('Basic Auth StatusCode 401: Unauthorized.'));
            else fs.writeFile(filePath, body, function(err) {
              if(err) reject(err);
              else resolve(filePath);
            });
          });
        });
github oxygenhq / oxygen / ox_modules / module-soap.js View on Github external
module.authBasic = function(user, pass) {
        auth = new soap.BasicAuthSecurity(user, pass);
    };
github seagull-js / seagull / packages / services-soap / src / mode / base.ts View on Github external
export const setSecurity = (client: ISoapClient, credentials: Credentials) => {
  const { username, password } = credentials
  client.setSecurity(new BasicAuthSecurity(username, password))
}
github sevenclev / node-soap-graphql / src / node-soap / node-soap.ts View on Github external
createClient(url, opts, (err: any, client: Client) => {
                if (err) {
                    reject(err);
                } else {
                    if (!!options.basicAuth) {
                        client.setSecurity(new BasicAuthSecurity(options.basicAuth.username, options.basicAuth.password));
                    }
                    resolve(client);
                }
            });
        } catch (err) {
github adamghill / exchanger / index.js View on Github external
soap.createClient(url, {}, function(err, client) {
    if (err) {
      return callback(err);
    }
    if (!client) {
      return callback(new Error('Could not create client'));
    }

    exports.client = client;
    exports.client.setSecurity(new soap.BasicAuthSecurity(settings.username, settings.password));

    return callback(null);
  }, endpoint);
}