隐私权和安全性最佳实践
使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。
以下是一些适用于在项目中使用 Google Assistant API 的开发者的安全和隐私权准则。
API 和应用授权
任何使用 Google Assistant API 的应用都必须具有授权凭据,用于向 Google 的身份验证服务器表明应用的身份。通常,这些凭据存储在下载的 client_secret_<client-id>.json
文件中。请务必将此文件存储在只有您的应用可以访问的位置。
您的应用可能会提示用户授予其 Google 帐号的访问权限。如果被授予,您的应用可以为该用户请求访问令牌。这些令牌会过期,但可以刷新。
设备上的未受保护的刷新令牌会带来重大安全风险。请确保您的应用满足以下要求:
- 将刷新令牌存储在安全的位置。
- 提供一种从设备清除令牌的简单方法。例如,提供可清除令牌的“退出”按钮(如果应用具有界面)或用户可以执行的命令行脚本。
- 通知用户,他们可以取消对 Google 帐号的访问权限。这会撤消刷新令牌;要再次使用应用,用户需要重新授予访问权限。
永久使用设备后,您应清除设备中的所有令牌。
有关详情,请参阅使用 OAuth 2.0 访问 Google API。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eApplications using the Google Assistant API require authorization credentials, typically stored in a \u003ccode\u003eclient_secret_<client-id>.json\u003c/code\u003e file, which should be kept secure.\u003c/p\u003e\n"],["\u003cp\u003eUser granted access allows applications to request access tokens that expire but can be refreshed; however, unprotected refresh tokens pose a security risk and should be stored securely with options for users to clear them.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers should inform users about the ability to deauthorize access to their Google account through Google's permissions page, which revokes the refresh token and requires re-authorization for further application use.\u003c/p\u003e\n"]]],["Applications using the Google Assistant API require authorization credentials, typically stored in a `client_secret` file, which should be securely stored. Applications may obtain user-specific access tokens, which can be refreshed. Refresh tokens must be securely stored, and applications should allow users to clear them, such as through a \"Sign out\" feature or a command line. Users should be informed that they can deauthorize application access, and all tokens should be cleared when a device is no longer used.\n"],null,["Here are some security and privacy guidelines for developers using the Google\nAssistant API in their projects.\n\nAPI and application authorization\n\nAny application that uses the Google Assistant API must have authorization\ncredentials that identify the application to Google's authentication server.\nTypically, these credentials are stored in a downloaded `client_secret_\u003cclient-id\u003e.json`\nfile. Make sure to store this file in a location that only your application\ncan access.\n\nYour application may prompt the user to grant it access to their Google account.\nIf granted, your application can request an access token for that user. These\ntokens expire, but can be refreshed.\n\nUnprotected refresh tokens on a device pose a significant security risk. Make\nsure your application:\n\n- Stores the refresh tokens in a secure place.\n- Provides an easy way to clear tokens from the device. For example, provide a \"Sign out\" button that clears a token (if the application has a UI) or a command line script that the user can execute.\n- Informs users that they can [deauthorize access](https://myaccount.google.com/permissions) to their Google account. This revokes the refresh token; to use the application again, the user would need to re-authorize access.\n\nWhen you are done using the device permanently, you should clear all of the\ntokens from it.\n\nFor more information, see [Using OAuth 2.0 to Access Google APIs](https://developers.google.com/identity/protocols/OAuth2)."]]