title: Avoiding DefaultCredentialsError when using google bigquery API
body: <p>I'm trying to execute an SQL query on some bigquery table. I keep getting a <code>DefaultCredentialsError</code> when trying to instantiate a bigquery client object. For example by doing this:</p>
  
  <pre><code>from google.cloud import bigquery
  client = bigquery.Client.from_service_account_json('service_account_key.json')
  </code></pre>
  
  <p>Or by doing this:</p>
  
  <pre><code>from oauth2client.service_account import ServiceAccountCredentials
  key = open('service_account_key.json', 'rb').read()
  
  credentials = ServiceAccountCredentials(
      'my_email',
      key,
      scope='https://www.googleapis.com/auth/bigquery')
  
  client = bigquery.Client(credentials=credentials)
  </code></pre>
  
  <p>Could there be a problem with my .json credentals file? I created a service account key:</p>
  
  <p><a href="https://i.stack.imgur.com/CPmfq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPmfq.png" alt="google api"></a></p>
  
  <p>Any other suggestions?</p>