I wanna make a very simple bash script for downloading files from google drive via Drive API
, so in this case there is a big file on google drive and I installed OAuth 2.0 Playground
on my google drive account, then in the Select the Scope
box, I choose Drive API v3
, and https://www.googleapis.com/auth/drive.readonly
to make a token and link.
After clicking Authorize APIs
and then Exchange authorization code for tokens
. I copied the Access token
like below.
#! /bin/bash
read -p 'Enter your id : ' id
read -p 'Enter your new token : ' token
read -p 'Enter your file name : ' file
curl -H "Authorization: Bearer $token" "https://www.googleapis.com/drive/v3/files/$id?alt=media" -o "$file"
but it won't work, any idea ?
for example the size of my file is 12G, when I run the code I will get this as output and after a second it back to prompt again ! I checked it in two computers with two different ip addresses.(I also add alt=media
to URL)
-bash-3.2# bash mycode.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 166 100 166 0 0 80 0 0:00:02 0:00:02 --:--:-- 80
-bash-3.2#
the content of file that it created is like this
{
"error": {
"errors": [
{
"domain": "global",
"reason": "downloadQuotaExceeded",
"message": "The download quota for this file has been exceeded."
}
],
"code": 403,
"message": "The download quota for this file has been exceeded."
}
}
If my understanding is correct, how about this modification?
Please add the query parameter of alt=media
.
curl -H "Authorization: Bearer $token" "https://www.googleapis.com/drive/v3/files/$id?alt=media" -o "$file"
If I misunderstood your question and this was not the direction you want, I apologize.