title: How to do o-auth in script and solve bigquery "login required" error
body: <p>I am trying to list column names of a <code>bigquery</code> table via app script.</p>
  
  <p>The code is something like:</p>
  
  <pre><code>var options = {'method': 'get', 'headers' : {'Content-Type':'application/json'}};     
  Logger.log(options); 
  
  var url = 'https://www.googleapis.com/bigquery/v2/projects/some_project_id/datasets/'+datasetId+'/tables/'+tableId     
  var response = UrlFetchApp.fetch(url, options).getContentText();
  </code></pre>
  
  <p>However it produces this error;</p>
  
  <blockquote>
    <p>Request failed for
    <a href="https://www.googleapis.com/bigquery/v2/projects/#####" rel="nofollow noreferrer">https://www.googleapis.com/bigquery/v2/projects/#####</a> returned code
    401. Truncated server response: { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required",
    "locationType": "header", ... (use muteHttpExceptions option to
    examine full response) (line 70, file "Code")</p>
  </blockquote>
  
  <p>I do not know how to use <code>o-auth</code> to access the <code>bigquery</code> from script. I also need to deploy the app as an add-on so that users can access their tables via the add-on for which they access in bigquery.</p>