<commit_before>
var request         = require( 'request' );
var app_const       = require( './const');


exports.init = function( org_name, app_name, client_id, client_secret){
  app_const.ORG_NAME      = org_name;
  app_const.APP_NAME      = app_name;
  app_const.CLIENT_ID     = client_id;
  app_const.CLIENT_SECRET = client_secret;
};

exports.init_token = function( org_name, app_name, client_id, client_secret){
  app_const.ORG_NAME      = org_name;
  app_const.APP_NAME      = app_name;
  app_const.CLIENT_ID     = client_id;
  app_const.CLIENT_SECRET = client_secret;
};




//通用http请求函数
var request_json = function (data, path, method, callback) {
    var options = {
        url: app_const.BASE_URL + app_const.ORG_NAME + '/' + app_const.APP_NAME + path,
        method : method ,
        json: data
    };
    request(options,callback);
};

//获取token
exports.get_token = function (callback) {
  var data = {grant_type: 'client_credentials', client_id: app_const.CLIENT_ID , client_secret: app_const.CLIENT_SECRET};
  request_json(data, '/token', 'POST', function (err,res,body) {
    if (!err && body && body.access_token){
      callback(null,body.access_token);
    }else{
      if(!err)
        err = 'unauthorized';
      callback(err,res.statusCode);
    }
  });
};


//通用http请求函数
exports.request_token = function (data, path, method,headers, callback) {

  if(!headers){
    headers = {};
  }
  headers.Authorization = 'Bearer ' + app_const.TOKEN;
  var options = {
    url     : app_const.BASE_URL + app_const.ORG_NAME + '/' + app_const.APP_NAME + path,
    method  : method ,
    headers : headers ,
    json    : data
  };
  console.log(app_const.TOKEN);


  console.log('==================');
  console.log(headers.Authorization);
  request(options,callback);
};

<commit_msg>删去log<commit_after>
var request         = require( 'request' );
var app_const       = require( './const');


exports.init = function( org_name, app_name, client_id, client_secret){
  app_const.ORG_NAME      = org_name;
  app_const.APP_NAME      = app_name;
  app_const.CLIENT_ID     = client_id;
  app_const.CLIENT_SECRET = client_secret;
};

exports.init_token = function( org_name, app_name, client_id, client_secret){
  app_const.ORG_NAME      = org_name;
  app_const.APP_NAME      = app_name;
  app_const.CLIENT_ID     = client_id;
  app_const.CLIENT_SECRET = client_secret;
};




//通用http请求函数
var request_json = function (data, path, method, callback) {
    var options = {
        url: app_const.BASE_URL + app_const.ORG_NAME + '/' + app_const.APP_NAME + path,
        method : method ,
        json: data
    };
    request(options,callback);
};

//获取token
exports.get_token = function (callback) {
  var data = {grant_type: 'client_credentials', client_id: app_const.CLIENT_ID , client_secret: app_const.CLIENT_SECRET};
  request_json(data, '/token', 'POST', function (err,res,body) {
    if (!err && body && body.access_token){
      callback(null,body.access_token);
    }else{
      if(!err)
        err = 'unauthorized';
      callback(err,res.statusCode);
    }
  });
};


//通用http请求函数
exports.request_token = function (data, path, method,headers, callback) {

  if(!headers){
    headers = {};
  }
  headers.Authorization = 'Bearer ' + app_const.TOKEN;
  var options = {
    url     : app_const.BASE_URL + app_const.ORG_NAME + '/' + app_const.APP_NAME + path,
    method  : method ,
    headers : headers ,
    json    : data
  };

  request(options,callback);
};


{'fraction_non_alphanumeric': 0.13463751438434982, 'fraction_numerical': 0.0, 'mean_word_length': 3.2714987714987713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3357027', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1222, 'n_words': 223}