Search code examples
curlgoogle-drive-apiwget

Google Drive API 403 error from wget/curl, but not from browser


I'm attempting to download a large file from Google Drive using wget or curl. I've set up a Drive API key to bypass the large file warning and need for authentication.

Putting the URL into a browser causes the immediate download as I desired (without my Google account being signed in). But when attempt to download with wget I get a 403 Forbidden error. Attempting to download with curl gives the following:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

The API key has no application restrictions. Why is this happening and how can I resolve it?

Edit, original call:

curl https://www.googleapis.com/drive/v3/files/FileID?alt=media&key=APIKey --output out

Solution

  • Thanks to @Hassan. Copying the cURL worked.

    Appearently what was missing was putting quotes around URL in the call to curl.

    Edit, new call:

    curl 'https://www.googleapis.com/drive/v3/files/FileID?alt=media&key=APIKey' --output out