Google 驱动器 RESTful 权限

Google Drive RESTful permissions

我正在尝试使用 JavaScript 和 Google 的 RESTful API 访问存储在团队 Google 驱动器中的一些文档。

我在开发者控制台设置了一个API密钥,并且限制在我的IP上。某些文档一切正常 - 我可以将 Google 文档导出为 HTML 并将其呈现在我的页面上。同样的页面也适用于 Postman。

但是,有些页面出现以下错误:

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "notFound",
                "message": "File not found: eg_xuQ5gXMWGPeUtf8mTZ7VhEYW_DIH6XK__lC1w0rMo",
                "locationType": "other",
                "location": "file"
            }
        ],
        "code": 404,
        "message": "File not found: eg_xuQ5gXMWGPeUtf8mTZ7VhEYW_DIH6XK__lC1w0rMo"
    }
}

我知道 fileId 是正确的,但我仍然收到 notFound 回复。我怀疑这与权限有关,但是当我比较 有效 的文档与 无效 的文档时,我看不出任何差异表面。

您可以参考此 ,其中问题出在 access_token。确保在对文件元数据发出 GET 请求时提供正确的 access_token。尝试重新生成授权码,access_token.

此外,如documentation所述,错误404: File not found: {fileId}表示用户没有文件的读取权限,或者文件不存在。

Suggested action: Report to users that they do not have read access to the file or that the file does not exist. Tell them that they should ask the owner for permission to the file.

希望对您有所帮助!