title: Login failed during python Insert job with BigQuery API
body: <p>I am trying load local file to bigquery by setting up a server-server auth.
  I've done following steps</p>
  
  <ol>
  <li>Created service account</li>
  <li>Create JSON key file for this account</li>
  <li><p>Activated service acount with </p>
  
  <p>gcloud auth activate-service-account command</p></li>
  <li><p>Logged in with </p>
  
  <p>gcloud auth login</p></li>
  <li><p>Trying to execute python script to upload file to BigQuery</p>
  
  <p>scopes = </p>
  
  <pre><code>['https://www.googleapis.com/auth/bigquery',
           'https://www.googleapis.com/auth/bigquery.insertdata']
  
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
      '/path/privatekey.json', scopes)
  # Construct the service object for interacting with the BigQuery API.
  service = build('bigquery', 'v2', credentials=credentials)
  
  # Load configuration with the destination specified.
  load_config = {
      'destinationTable': {
          'projectId': "project id",
          'datasetId': "data set id",
          'tableId': "table name"
      }
  }
  
  # Setup the job here.
  # load[property] = value
  load_config['schema'] = {
      'fields': [
          &lt;several field&gt;
      ]
  }
  
  
  upload = MediaFileUpload('/path/to/csv/file',
                           mimetype='application/octet-stream',
                           # This enables resumable uploads.
                           resumable=True)
  # End of job configuration.
  
  run_load.start_and_wait(service.jobs(),
                          "my project id",
                          load_config,
                          media_body=upload)
  </code></pre></li>
  <li><p>The result is </p>
  
  <pre><code>   "error": {
      "errors": [
     {
      "domain": "global",
      "reason": "required",
      "message": "Login Required",
      "locationType": "header",
      "location": "Authorization"
     }
    ],
    "code": 401,
    "message": "Login Required"
   }
  }
  </code></pre></li>
  <li><p>But I have enough rights to create query jobs</p>
  
  <pre><code>query_request = service.jobs()
  query_data = {
      'query': (
          'SELECT COUNT(*) FROM [dmrebg.testDay];')
  }
  
  query_response = query_request.query(
      projectId=project_id,
      body=query_data).execute()
  
  print('Query Results:')
  for row in query_response['rows']:
      print('\t'.join(field['v'] for field in row['f']))
  </code></pre></li>
  </ol>
  
  <hr>
  
  <p>What did I miss? I thought that I've already logged in.</p>