首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GoogleDrive访问APIKey文件

使用GoogleDrive访问APIKey文件
EN

Stack Overflow用户
提问于 2019-09-20 14:40:11
回答 1查看 364关注 0票数 1

我正在尝试创建一个nodejs应用程序,它可以准备好我的 GoogleDrive文件。我不想要每个人都可以使用的应用程序,它只适用于我的GoogleDrive。所以不需要OAuth..。

我在控制台中为GoogleDrive创建了一个api键,没有任何限制。

这就是我正在打的电话:钥匙

使用此键时,我会得到以下错误:

代码语言:javascript
复制
{
 "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中是可能的吗?

我必须在某个地方设置权限吗?

我在这里错过了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-22 06:47:59

这个答案怎么样?

问题:

API密钥用于公开共享的内容。因此,如果您试图访问未与API密钥公开共享的文件,即使该文件是您的,也会发生错误。

API密钥可用于GET方法。API键不能用于POST和PUT方法。请小心这个。

解决方案:

为了访问Google上的文件,下面的方法如何?

  1. 公开共享该文件,然后使用API键访问该文件。
代码语言:javascript
复制
- In this case, the file cannot be written with API key even if the shared file is publicly shared as the editable permission.

  1. 如果您想在不公开共享的情况下访问文件,那么使用服务帐户或OAuth2检索的访问令牌如何?
代码语言:javascript
复制
- 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.

参考文献:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58030536

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档