Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TBase.prototype.apply_auth = function (url, args, user) {
user.authtype = user.authtype || 'oauth';
args.headers = args.headers || {};
if (user.authtype === 'baseauth') {
if (user.username && user.password) {
args.headers.Authorization = urllib.make_base_auth_header(user.username, user.password);
}
} else if (user.authtype === 'oauth' || user.authtype === 'xauth') {
var accessor = {
consumerSecret: this.config.secret
};
// 已通过oauth认证
if (user.oauth_token_secret) {
accessor.tokenSecret = user.oauth_token_secret;
}
var parameters = {};
for (var k in args.data) {
parameters[k] = args.data[k];
if (k.substring(0, 6) === 'oauth_') { // 删除oauth_verifier相关参数
delete args.data[k];
}