title: 403 From Google Drive API When Using API Key
body: <p>I've got a Kotlin application that retrieves publicly availably PDFs stored on Google drive.  To download the PDFs, I do the following</p>
  <pre><code>@Throws(IOException::class)
  fun download(url: String?, destination: File?) {
      val connection: URLConnection = URL(url).openConnection()
      connection.setConnectTimeout(60000)
      connection.setReadTimeout(60000)
      connection.addRequestProperty(&quot;User-Agent&quot;, &quot;Mozilla/5.0&quot;)
      val output = FileOutputStream(destination, false)
      val buffer = ByteArray(2048)
      var read: Int
      val input: InputStream = connection.getInputStream()
      while (input.read(buffer).also { read = it } &gt; -1) output.write(buffer, 0, read)
      output.flush()
      output.close()
      input.close()
  }
  </code></pre>
  <p>My url is of the form <code>https://www.googleapis.com/drive/v3/files/${fileId}?key=&lt;MY_KEY&gt;&amp;alt=media</code>.</p>
  <p>Google seems to be rejecting requests after it serves about 10 requests. I checked the API usage, and it says I get 20,000 requests per 100 seconds (<a href="https://developers.google.com/drive/api/guides/limits" rel="nofollow noreferrer">https://developers.google.com/drive/api/guides/limits</a>).  I can see my requests on the API usage chart, so the API key is being recognized. I'm using 10-15 requests then getting the 403.  It's not coming back as json, so here is the detailed message:</p>
  <blockquote>
  <p>We're sorry...<br />
  ... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.<br />
  See <a href="https://support.google.com/websearch/answer/86640" rel="nofollow noreferrer">Google Help</a> for more information.</p>
  </blockquote>
  <p>I assume I'm missing something obvious.  In that HTML blob, it says <code>but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</code>, which is obviously what I'm trying to do.</p>
  <p>Do I need to use a different method to pull a couple hundred PDFs from Drive?</p>