我想制作一个非常简单的 bash 脚本,用于通过 google 驱动器下载文件Drive API
,所以在这种情况下,谷歌驱动器上有一个大文件,我安装了OAuth 2.0 Playground
在我的谷歌驱动器帐户上,然后在Select the Scope
盒子,我选择Drive API v3
, and https://www.googleapis.com/auth/drive.readonly
制作令牌和链接。
点击后Authorize APIs
进而Exchange authorization code for tokens
。我复制了Access token
像下面这样。
#! /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"
但这行不通,有什么想法吗?
例如,我的文件大小是 12G,当我运行代码时,我会将其作为输出,一秒钟后它会再次提示!我在两台具有两个不同IP地址的计算机上检查了它。(我还添加了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#
它创建的文件的内容是这样的
{
"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."
}
}