- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Electron 应用程序需要访问用户 Google Drive,我想实现 api 功能而不必公开客户端密码。据我所知,这在某些情况下是不可能的,例如移动应用程序,但在本地应用程序上执行此操作的正确方法是什么?
尝试跟随 web-app 时来自 Google 的 OAuth 说明,看起来您不能在本地应用程序上使用此方法。当尝试以这种方式设置 OAuth 流程时,它甚至不允许您将 localhost 作为域列入白名单以对用户进行身份验证(这会破坏流程,因为这是在 Electron 上运行的本地应用程序)。再加上这个 paper谷歌发布了,你似乎也不能欺骗授权进程认为它没有在本地主机上运行,你也不能在浏览器中运行 Node.js(我使用的是 Electron,所以这是不可能的) .
然后我尝试关注他们的 Mobile and Desktop app看起来很有希望的工作流程。当您需要 Exchange authorization code for refresh and access tokens 时,问题就出现了.这再次要求您在主应用程序中显示您的客户端密码。然后我将其拆分并在本地执行其中的一些操作,然后拥有一个验证服务器来保存客户端 secret 并从客户端交换授权代码并返回刷新和访问 token 。看着 diagram Google 提供了可视化此过程的功能,它清楚地表明您的应用需要执行授权过程的两个部分,因此这个想法也被淘汰了。
我个人使用和查看的一个应用程序是 rclone,从外观上看,他们只是在他们的 code 中直接列出了他们的客户端 ID 和密码。 .客户端 secret 已加密,但如果您按照工作流程进行操作,它会通过同样为 stored locally on the app 的 key 显示出来。 .所以它的纯文本是模糊的,但是没有什么可以阻止任何人通过稍微修改代码来获取客户端 secret 。
我还应该提到这个应用程序在 GitHub 上的公共(public)存储库中,并将保持这种状态。
这是我第一次使用 OAuth,所以我可能误解了一些东西,但我尝试尽可能仔细地遵循文档并且无法摆脱我忽略了这个过程的一部分的感觉。
如果解决此问题的唯一方法是公开客户端 ID 和密码,这是否会导致用户数据泄露?由于 Google Drive API 是免费使用的,所以我并不介意其他人使用我的部分配额。我更担心安全问题。
最佳答案
对于您正在开发的桌面应用等公共(public)客户端,您需要使用 PKCE 流程。没错,Google 的文档似乎不在此处 - 您不需要将 client_secret
作为授权代码交换的一部分传递。
这里的文档支持:https://www.oauth.com/oauth2-servers/pkce/authorization-code-exchange/
Google 可能需要 client_secret
,但它并未将该参数视为公共(public)客户的真正“ secret ”,而是一个不敏感的附加标识符,并且在其上不够充分拥有代表您的应用程序做任何事情。 Section 8.5 of the specification阅读:
Secrets that are statically included as part of an app distributed tomultiple users should not be treated as confidential secrets, as oneuser may inspect their copy and learn the shared secret. For thisreason, and those stated in Section 5.3.1 of [RFC6819], it is NOTRECOMMENDED for authorization servers to require client authentication of public native apps clients using a shared secret,as this serves little value beyond client identification which isalready provided by the "client_id" request parameter.
Authorization servers that still require a statically included sharedsecret for native app clients MUST treat the client as a publicclient (as defined by Section 2.1 of OAuth 2.0 [RFC6749]), and notaccept the secret as proof of the client's identity. Withoutadditional measures, such clients are subject to client impersonation(see Section 8.6).
您还可以查看独立的 OAuth 服务提供商,例如 Xkit我工作的地方。这样一来,您就可以在继续执行 OAuth 流程的同时对 secret 保密。
关于node.js - 如何在 Electron 应用程序上正确存储 Google Drive API 的客户端 secret ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65722648/
我正在尝试使用 Drive SDK 将文件上传到 Google Drive . 我想知道是否有 API 方法来检查用户的驱动器是否有足够的容量来保存文件。如果是,请指出我应该搜索的位置,如果不是,最好
我想在我正在开发的新 android 应用程序(又名 drive.appdata 范围)中使用特殊应用程序数据文件夹中的文件。 谷歌的你们在与 Google Play Services 4.2 捆绑的
列出Google云端硬盘文件的JavaScript示例使用gapi.client.drive.files.list()。 尝试使用此方法时,出现错误“无法读取未定义的属性'files'”。 该问题和解
我正在尝试使用 Google Cloud REST API 获取特定文件夹大小。 我已经尝试过使用 REST API 的“ about ”方法,但在这种方法中,我获得了整个云存储的已用字节总数和可用空
我只是想了解在 G Suite 上使用 Team Drive 获取团队存储库与仅使用 Google Drive 上的共享文件夹相比的优势。通过搜索不同的来源并进行测试,到目前为止我发现了以下结果。 坦
我正在尝试使用 Google Drive API (v3) 更新文档 在 Google 云端硬盘中。 我已阅读此迁移指南: Google Drive API v3 Migration 并对其进行编码以
我曾尝试将我的 Web 应用程序集成到 Google 云端硬盘用户界面(以打开文件),但没有取得多大成功。我无法使用 OAuth 范围 https://www.googleapis.com/auth/
使用Google Drive API时 我使用 com.google.api.services.drive.Drive.files() 来迭代一些文件。 我注意到所有目录对象都没有权限? 当我使用 F
Google Drive API 和 Google Spreadsheet API (v 3.0) 都支持获取与以下 URL 对应的 [KEY] 的方法: https://docs.google.co
我正在尝试将本地 CSV 文件上传到 Google Drive 并在那里像 Google 电子表格一样显示它。但是,当我转到 Google Drive 并单击指向我的文件的链接时,我只能下载它,而不能
我正在尝试使用 ArrayBuffer 的内容在 Google Drive 上创建一个文件。我正在使用 Javascript 和 Drive API 的第 3 版。 我设法使用 this code s
我可以使用 google drive android api 将文本文件上传到 google drive 中的文件夹。 Sample code 但是我想上传一张图片到谷歌驱动器。这可能吗? 创建文本文
我想知道以下是否可行,因为我似乎无法在网上找到任何具体的方法: 当 Google Takeaway 服务将新的 takeout-xxx.zip 文件上传到我的 Google Drive Takeawa
是否可以对 Google Drive 上的文件执行“追加”操作? 假设我想使用 Google Drive 保存日志条目“as-they-come-in”,是否有某种“仅附加”操作可用? 最佳答案 如果
看着 Google Drive scopes .我明白: https://www.googleapis.com/auth/drive.install - 用于让用户批准安装应用程序的特殊范围 如果我希
我有一个带有两个父文件夹( FILE-1 和 FOLDER-1 )的文档( FOLDER-2 )。 如果我删除 FOLDER-1 , FILE-1也被删除。然而,我预计只有FOLDER-1将被删除,并
我正在测试Google Drive API。测试脚本执行HTTP GET来访问Files-> List API,但是我总是以某种方式在项目中得到一个空列表。我的Google驱动器中有数百个文件,因此结
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我将我的应用程序的文件托管在 Google Drive 上,它会在首次启动后立即下载它们。一切都很好,但在我发布新的应用程序版本后,下载数量不断增加,文件由于某些原因变得不可用。虽然我没有改变任何东西
我是一名优秀的程序员,十分优秀!