lib/Auth.js
function (code) {
    var params;
    var headers = { 'Content-Type': 'application/x-www-form-urlencoded' };


    if (this.private) {
      headers.Authorization = 'Basic ' +  Buffer.from(this.app_key + ':' + this.app_secret).toString('base64');
      params = {
        grant_type: 'client_credentials'
      };
    } else {
      if (arguments.length < 1) {
        throw paramError;
      }
      params = {
        grant_type: 'authorization_code',
        code: code,
        client_id: this.app_key,
        redirect_uri: this.redirect_url ? this.redirect_url : this.callback_url
      };
    }

    var option = {
      hostname: this.host,
      path: '/oauth2/token',
      method: 'POST',
      headers: headers
    };
    return this._request.request(option, params).then(function (data) {
      if (!data.token.length) {
        throw new Error('无效的 token');
      }
      return data.token;
    });
  }
function (code) {
    var params;
    var headers = { 'Content-Type': 'application/x-www-form-urlencoded' };


    if (this.private) {
      headers.Authorization = 'Basic ' +  Buffer.from(this.app_key + ':' + this.app_secret).toString('base64');
      params = {
        grant_type: 'client_credentials'
      };
    } else {
      if (arguments.length < 1) {
        throw paramError;
      }
      params = {
        grant_type: 'authorization_code',
        code: code,
        client_id: this.app_key,
        redirect_uri: this.redirect_url ? this.redirect_url : this.callback_url
      };
    }

    var option = {
      hostname: this.host,
      path: '/oauth2/token',
      method: 'POST',
      headers: headers
    };
    return this._request.request(option, params).then(function (data) {
      if (!data.token.length) {
        throw new Error('无效的 token');
      }
      return data.token;
    });
  }
获取 token
@param {string} code，用于开放应用
@returns {Object<Promise>}