title: Proxy problems in Google API
body: <p>Now I'm developing a Google Calendar application with node.js programs. And now I'm facing proxy troubles.</p>
  
  <p>Firstly I've tried google's test sample and it worked if my node.js program accesses Internet directly (I mean without proxy). But when I tried to run same program in proxy environment, it failed. I use same code below link except for proxy settings.</p>
  
  <p><a href="https://developers.google.com/google-apps/calendar/quickstart/nodejs" rel="nofollow">quickstart</a> </p>
  
  <pre><code> var fs = require('fs');
   var readline = require('readline');
   var google = require('googleapis');
   var googleAuth = require('google-auth-library');
  
   google.options.proxy = 'https://xxx:12345'; // I added
   process.env.HTTP_PROXY = 'http://xxx:12345'; // I added
   process.env.HTTPS_PROXY = 'https://xxx:12345'; // I added
   ///
  </code></pre>
  
  <p>It failed when trying to get a token. Actually this proxy is valid because I use same proxy setting on the same pc.</p>
  
  <pre><code>Error while trying to retrieve access token { [Error: tunneling socket could not be established, cause=139916950681408:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:787:
  ] code: 'ECONNRESET' }
  </code></pre>
  
  <p>For debugging, I added code to printing options at TunnelingAgent():google-auth-library/node_modules/request/node_modules/tunnel-agent/index.js. And I confirmed 
  proxy settings are printed like below.</p>
  
  <pre><code>options: { proxy:
     { host: 'xxx',
       port: 12345,
       proxyAuth: null,
       headers:
        { 'User-Agent': 'google-api-nodejs-client/0.9.7',
          host: 'accounts.google.com:443' } },
    headers: { 'User-Agent': 'google-api-nodejs-client/0.9.7' },
    ca: undefined,
    cert: undefined,
    key: undefined,
    passphrase: undefined,
    pfx: undefined,
    ciphers: undefined,
    rejectUnauthorized: undefined,
    secureOptions: undefined,
    secureProtocol: undefined }
  </code></pre>
  
  <p>What happens?</p>
  
  <p>My refs:</p>
  
  <ul>
  <li><p><a href="https://github.com/google/google-api-nodejs-client/#example-specifying-a-default-proxy-and-auth-to-be-used-for-each-request" rel="nofollow">specifying a default proxy and auth to be used for each request</a></p></li>
  <li><p><a href="https://github.com/google/google-api-nodejs-client/issues/64" rel="nofollow">issue with Sent requests via HTTP proxy</a>  </p></li>
  </ul>