【发布时间】:2019-08-06 11:28:10
【问题描述】:
我正在尝试使用 curl 获取 Google 云端硬盘上的文件列表,但 OAuth 2 对我来说是最好的。
以下是我尝试过的一些事情:
curl -H "Authorization: Bearer $token" https://www.googleapis.com/drive/v2/files
其中 $token 是我使用的 460 个字符的字符串:
https://www.google.com/accounts/ClientLogin
还有这个上传script(效果很好)。这是我收到的错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
也试过了:
curl https://www.googleapis.com/drive/v2/files?key=apiKey
错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
还有:
curl -H "Authorization: GoogleLogin auth=${token}" "https://www.googleapis.com/drive/v2/files"
错误:
{
"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."
}
}
我在 JavaScript 和 PHP 客户端库上都没有成功,它们似乎都针对用户提供日志/通行证以授权应用程序的情况进行了优化。我需要的是一种每次都列出来自单个帐户的文件的方法。
【问题讨论】:
标签: curl google-drive-api