docs: def _InvokeGitkitApi(self, method, params=None, need_service_account=True):
      """Invokes Gitkit API, with optional access token for service account.
  
      Args:
        method: string, the api method name.
        params: dict of optional parameters for the API.
        need_service_account: false if service account is not needed.
  
      Raises:
        GitkitClientError: if the request is bad.
        GitkitServerError: if Gitkit can not handle the request.
  
      Returns:
        API response as dict.
      """
      body = simplejson.dumps(params) if params else None
      req = urllib_request.Request(self.google_api_url + method)
      req.add_header('Content-type', 'application/json')
      if need_service_account:
        if self.credentials:
          access_token = self.credentials.get_access_token().access_token
        elif self.service_account_email and self.service_account_key:
          access_token = self._GetAccessToken()
        else:
          raise errors.GitkitClientError('Missing service account credentials')
        req.add_header('Authorization', 'Bearer ' + access_token)
      try:
        binary_body = body.encode('utf-8') if body else None
        raw_response = urllib_request.urlopen(req, binary_body).read()
      except urllib_request.HTTPError as err:
        if err.code == 400:
          raw_response = err.read()
        else:
          raise
      return self._CheckGitkitError(raw_response)