title: importing to BigQuery via cron and refresh_and_apply_credential getting 'NoneType' object has no attribute 'apply'
body: <p>I have a cron job that fetches Datastore dump from Google Storage. </p>
  
  <p>I have tested this Datastore dump by manually importing to BigQuery with these settings:</p>
  
  <p><a href="https://i.stack.imgur.com/Wp0fa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wp0fa.png" alt="enter image description here"></a></p>
  
  <p>and it imports just fine into BigQuery.</p>
  
  <p>My code uses <code>import googleapiclient.discovery</code> and it would look something like this:</p>
  
  <pre><code>service = googleapiclient.dis covery.build('bigquery', 'v2')
  
  batch = service.new_batch_http_request(callback=insert_bigquery)
  
  # more stuff... 
  
  # and it will fail here
  response = batch.execute()
  </code></pre>
  
  <p>And the error from the logs would look something like this:</p>
  
  <blockquote>
    <p>AttributeError: 'NoneType' object has no attribute 'apply' at
    _refresh_and_apply_credentials (/base/data/home/apps/my-app/import-bq.419067140342338621/lib/googleapiclient/http.py:1039)
    at execute
    (/base/data/home/apps/my-app/import-bq.419067140342338621/lib/googleapiclient/http.py:1318)
    at positional_wrapper
    (/base/data/home/apps/my-app/import-bq.419067140342338621/lib/oauth2client/util.py:142)
    at get
    (/base/data/home/apps/my-app/import-bq.419067140342338621/handlers/cron.py:97)
    at dispatch
    (/base/alloc/tmpfs/dynamic_runtimes/python27g/6a5167f0cae8960d/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py:570)
    at dispatch
    (/base/alloc/tmpfs/dynamic_runtimes/python27g/6a5167f0cae8960d/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py:572)
    at dispatch
    (/base/data/home/apps/my-app/import-bq.419067140342338621/base/handlers.py:224)
    at dispatch
    (/base/data/home/apps/my-app/import-bq.419067140342338621/base/handlers.py:297)</p>
  </blockquote>
  
  <p>Can someone explain what's going on and what things can i try to make this work?</p>
  
  <p>Thank you.</p>