lib/internal/make-api-call.js
function formatRequestUrl(path, query, useClientId) {
    if (channel) {
      query.channel = channel;
    }
    if (useClientId) {
      query.client = clientId;
    } else if (key && key.indexOf('AIza') == 0) {
      query.key = key;
    } else {
      throw 'Missing either a valid API key, or a client ID and secret';
    }

    var requestUrl = url.format({pathname: path, query: query});

    // When using client ID, generate and append the signature param.
    if (useClientId) {
      var secret = new Buffer(clientSecret, 'base64');
      var payload = url.parse(requestUrl).path;
      var signature = computeSignature(secret, payload);
      requestUrl += '&signature=' + encodeURIComponent(signature);
    }

    return requestUrl;
  }
function formatRequestUrl(path, query, useClientId) {
    if (channel) {
      query.channel = channel;
    }
    if (useClientId) {
      query.client = clientId;
    } else if (key && key.indexOf('AIza') == 0) {
      query.key = key;
    } else {
      throw 'Missing either a valid API key, or a client ID and secret';
    }

    var requestUrl = url.format({pathname: path, query: query});

    // When using client ID, generate and append the signature param.
    if (useClientId) {
      var secret = new Buffer(clientSecret, 'base64');
      var payload = url.parse(requestUrl).path;
      var signature = computeSignature(secret, payload);
      requestUrl += '&signature=' + encodeURIComponent(signature);
    }

    return requestUrl;
  }
function formatRequestUrl ( path , query , useClientId ) { if ( channel ) { query . channel = channel ; } if ( useClientId ) { query . client = clientId ; } else if ( key && key . indexOf ( 'AIza' ) == 0 ) { query . key = key ; } else { throw 'Missing either a valid API key, or a client ID and secret' ; } var requestUrl = url . format ( { pathname : path , query : query } ) ; // When using client ID, generate and append the signature param. if ( useClientId ) { var secret = new Buffer ( clientSecret , 'base64' ) ; var payload = url . parse ( requestUrl ) . path ; var signature = computeSignature ( secret , payload ) ; requestUrl += '&signature=' + encodeURIComponent ( signature ) ; } return requestUrl ; }
Adds auth information to the query, and formats it into a URL.
@param {string} path
@param {Object} query
@param {boolean} useClientId
@return {string} The formatted URL.
Adds auth information to the query and formats it into a URL .