title: Invalid Credentials accessing Big Query tables from App Engine application
body: <p>Could someone help me access Big Query from an App Engine application ?</p>
  
  <p>I have completed the following steps -</p>
  
  <p>Created an App Engine project.</p>
  
  <p>Installed google-api-client, oauth2client dependencies (etc) into /lib.</p>
  
  <p>Enabled the Big Query API for the App Engine project via the cloud console.</p>
  
  <p>Created some 'Application Default Credentials' (a 'Service Account Key') [JSON] and saved it/them to the root of the App Engine application.</p>
  
  <p>Created a 'Big Query Service Resource' as per the following -</p>
  
  <pre><code>def get_bigquery_service():
      from googleapiclient.discovery import build
      from oauth2client.client import GoogleCredentials
      credentials=GoogleCredentials.get_application_default()
      bigquery_service=build('bigquery', 'v2', credentials=credentials)
      return bigquery_service
  </code></pre>
  
  <p>Verified that the resource exists - </p>
  
  <pre><code>&lt;googleapiclient.discovery.Resource object at 0x7fe758496090&gt;
  </code></pre>
  
  <p>Tried to query the resource with the following (ProjectId is the short name of the App Engine application) - </p>
  
  <pre><code>bigquery=get_bigquery_service()
  bigquery.tables().list(projectId=#{ProjectId},
                     datasetId=#{DatasetId}).execute()
  </code></pre>
  
  <p>Returns the following -</p>
  
  <pre><code>&lt;HttpError 401 when requesting https://www.googleapis.com/bigquery/v2/projects/#{ProjectId}/datasets/#{DatasetId}/tables?alt=json returned "Invalid Credentials"&gt;
  </code></pre>
  
  <p>Any ideas as to steps I might have wrong or be missing here ? The whole auth process seems a nightmare, quite at odds with the App Engine/PaaS ease-of-use ethos :-(</p>
  
  <p>Thank you.</p>