我正在尝试创建一个nodejs应用程序,它可以准备好我的 GoogleDrive文件。我不想要每个人都可以使用的应用程序,它只适用于我的GoogleDrive。所以不需要OAuth..。
我在控制台中为GoogleDrive创建了一个api键,没有任何限制。
这就是我正在打的电话:钥匙
使用此键时,我会得到以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientFilePermissions",
"message": "The user does not have sufficient permissions for this file."
}
],
"code": 403,
"message": "The user does not have sufficient permissions for this file."
}
}这在GoogleDrive中是可能的吗?
我必须在某个地方设置权限吗?
我在这里错过了什么?
发布于 2019-09-22 06:47:59
这个答案怎么样?
问题:
API密钥用于公开共享的内容。因此,如果您试图访问未与API密钥公开共享的文件,即使该文件是您的,也会发生错误。
API密钥可用于GET方法。API键不能用于POST和PUT方法。请小心这个。
解决方案:
为了访问Google上的文件,下面的方法如何?
- In this case, the file cannot be written with API key even if the shared file is publicly shared as the editable permission.
- If the access token retrieved by OAuth2 is used, it is required to authorize by own browser.
- If the service account is used, you can retrieve the access token without authorizing with own browser.
参考文献:
https://stackoverflow.com/questions/58030536
复制相似问题