帐号关联

每个 smart home Action 都必须包含用户身份验证机制。

通过身份验证,您可以将用户的 Google 帐号与用户在您的身份验证系统中的帐号相关联。这样,您就可以在您的执行方式收到智能家居 intent 时识别用户。Google 智能家居仅支持包含授权代码流程的 OAuth。

拥有 OAuth 2.0 实现后,您可以选择配置基于 OAuth 的 App Flip,这可让您的用户更快地将其在您的身份验证系统中的帐号关联到他们的 Google 帐号。

OAuth

对于 smart home,您必须使用带有授权代码流程的 OAuth,这要求您有两个端点:授权端点和令牌交换端点。

您对用户进行身份验证后,当 smart home intent 发送到您的执行方式时,系统会在授权标头中发送该用户的第三方 OAuth 2.0 访问令牌。所有用户都必须执行帐号关联操作,因为设备信息会随 action.devices.SYNC intent 一起发送到 Google Assistant,而这需要关联帐号。

您的 smart home Action 应能支持将多个 Google 用户关联到同一用户帐号(例如,当用户向其他家庭用户授予访问权限时)。如果您的服务不支持关联多名用户,系统应该会在帐号关联时提供错误消息。

如需了解如何为 Action 设置 OAuth 2.0 服务器,请参阅实现 OAuth 2.0 服务器

基于 OAuth 的应用快速关联

OAuth-based App Flip Linking (App Flip) allows your users to easily and quickly link their accounts in your authentication system to their Google accounts. If your app is installed on your user’s phone when they initiate the account linking process, they are seamlessly flipped to your app to obtain user authorization.

This approach provides a faster and easier linking process since the user does not have to re-enter their username and password to authenticate; instead, App Flip leverages the credentials from the user's account on your app. Once a user has linked their Google account with your app, they can take advantage of any integrations that you have developed.

You can set up App Flip for both iOS and Android apps.

This figure shows the steps for a user to link their Google account
            to your authentication system. The first screenshot shows how a user
            can select your app if their Google account is linked to your app.
            The second screenshot shows the confirmation for linking their
            Google account with your app. The third screenshot shows a
            successfully linked user account in the Google app.
Figure 1. Account linking on a user's phone with App Flip.

Requirements

To implement App Flip, you must fulfill the following requirements:

  • You must have an Android or iOS app.
  • You must own, manage and maintain an OAuth 2.0 server which supports the OAuth 2.0 authorization code flow.

如需详细了解 OAuth 关联授权代码流,请参阅实现 OAuth 2.0 服务器

如需了解如何为 Action 配置 App Flip,请参阅基于 OAuth 的 App Flip