使用Curl将文件上传到Google云端硬盘会显示401

阿什温

我正在尝试使用将本地系统上的文件上传到我的google驱动器帐户Curl我转到Google Developer Console并启用了Google Drive API,创建了一个API-KEY
这是我的卷曲要求

curl -X POST -L \
    -H "Authorization: Bearer my_API-KEY" \
    -F "metadata={name : 'JUMBA'};type=application/json;charset=UTF-8" \
    -F "file=@my_file.json;type=application/zip" \
    "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"

但是我得到这个错误-

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}

该文档也不是很清楚。这里有什么帮助吗?

戴姆敦

“授权:承载my_API-KEY”

授权标头应包含承载令牌。承载令牌是JWT访问令牌。api密钥是仅用于访问公共数据的公共密钥。您需要经过授权过程并请求访问令牌,然后才能执行此操作。

# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.

# Authorization link.  Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=[Scopes]&response_type=code

# Exchange Authorization code for an access token and a refresh token.

curl \
--request POST \
--data "code=[Authentcation code from authorization link]&client_id=[Application Client Id]&client_secret=[Application Client Secret]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" \
https://accounts.google.com/o/oauth2/token

# Exchange a refresh token for a new access token.
curl \
--request POST \
--data 'client_id=[Application Client Id]&client_secret=[Application Client Secret]&refresh_token=[Refresh token granted by second step]&grant_type=refresh_token' \
https://accounts.google.com/o/oauth2/token

GoogleAuthenticationCurl.sh如果您在更改Google云端硬盘时遇到任何问题,告诉我。您也可以检查我对这个相关问题的回答1841839

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用php curl将文件上传到Google云端硬盘

将文件上传到Google云端硬盘?

使用cURL将文件上传到Google云端硬盘-access_token过期问题

使用gapi将文件上传到Google云端硬盘

使用Dropzone将文件上传到Google云端硬盘

使用意图将文件上传到Google云端硬盘

在后台将文件上传到Google云端硬盘

将文件从网络上传到Google云端硬盘

将文件从Blobstore上传到Google云端硬盘

使用http上传到Google云端硬盘文件夹

使用Windows服务自动将文件上传到Google云端硬盘文件流

Python:如何使用folderId将文件上传到Google云端硬盘中的特定文件夹

使用PyDrive将图片上传到Google云端硬盘

使用Android将文本文件上传到Google云端硬盘

使用javascript(无html表单)以编程方式将文件上传到Google云端硬盘

如何使用Apps脚本将云端硬盘中的现有文件上传到云端硬盘

Google云端硬盘API将文件上传到Java团队硬盘

如何使用REST API将新修订版本上传到Google云端硬盘中的特定文件?

无法将文件上传到Google云端硬盘中的文件夹

无法将文件上传到Google云端硬盘上的特定文件夹

将文件上传到Google云端硬盘中的特定文件夹

Angular Gapi将简单文本上传到Google云端硬盘

将文件上传到Google云端硬盘后,如何处理该事件(调用脚本)?

将内存中的文件下载并上传到Google云端硬盘

通过Javascript API将多个文件上传到Google云端硬盘的最佳策略

可靠地将大文件上传到Google云端硬盘

通过HTTP请求(C)将文件上传到Google云端硬盘

C:通过HTTP请求将文件上传到Google云端硬盘的错误408响应

如何将持续更新的文件夹上传到Google云端硬盘?