以这种方式重新发送 MESSAGE 互动事件时,该事件应与原始事件完全相同;不过,在某些情况下,MESSAGE 互动事件可能会有所不同。例如,当某条消息同时提及 Chat 应用 A 和 Chat 应用 B 时,如果 Chat 应用 A 在通过 Chat 应用 B 进行身份验证之前回复了常规消息,则用户能够修改该消息。在这种情况下,聊天应用 B 会在用户完成身份验证和配置后收到修改后的消息文本。
在 Chat 之外对 Chat 用户进行身份验证
在某些情况下(例如为 API 请求 OAuth 授权),您的应用需要链接到 Chat 之外的网址,同时保持用户身份。在这些情况下,识别用户的最佳方式是使用 Google 登录保护目标应用。
使用登录期间签发的身份令牌获取用户 ID。sub 声明包含用户的唯一 ID,可与 Google Chat 中的用户 ID 相关联。
虽然这两个 ID 并不完全相同,但可以强制转换。如需将 sub 声明的值强制转换为 Google Chat users/{user},请在值前面添加 users/。例如,声明值 123 相当于发送给 Chat 应用的消息中的用户名 users/123。
[[["易于理解","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-08-29。"],[[["\u003cp\u003eGoogle Chat apps can connect with external services for enhanced functionality, such as account linking and data access.\u003c/p\u003e\n"],["\u003cp\u003eTo enable external connections, Chat apps use a configuration URL that prompts users to complete setup outside of Chat.\u003c/p\u003e\n"],["\u003cp\u003eUpon successful configuration, the original message in Chat becomes public and is resent to the app for processing.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Sign-in is recommended for authenticating Chat users in external systems by using the identity token's \u003ccode\u003esub\u003c/code\u003e claim.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the identity token's integrity is validated before using the user ID for any operations.\u003c/p\u003e\n"]]],["To connect a Google Chat app with external services, use a configuration URL returned in a `REQUEST_CONFIG` response, prompting users for authentication or configuration. This URL should include the `configCompleteRedirectUrl` provided by Chat, redirecting users back upon completion. Successful redirection erases the prompt, makes the original message public, and resends the original message to the Chat app. To maintain user identity outside Chat, use Google Sign-in and validate the integrity of the `sub` token.\n"],null,[]]