应用快速关联

拥有 OAuth 2.0 实现后,您可以选择配置基于 Auth 的 App Flip,以便让用户能够更快地将其在您的身份验证系统中的帐号关联到他们的 Google 帐号。下面几部分将介绍如何为 smart home Action 设计和实现 App Flip

Design guidelines

This section describes the design requirements and recommendations for the App Flip account linking consent screen. After Google calls your app, your app displays the consent screen to the user.

Requirements

  1. You must have a Google authorization statement such as "Once linked, Google will have permission to control your devices."
  2. You must communicate that the user's account is being linked to Google, not to a specific Google product, such as Google Home or Google Assistant.
  3. You must state a clear call-to-action on your consent screen and use the wording "Agree and link" for linking action. This is because users need to understand what data they're required to share with Google to link their accounts.
  4. You must provide a way for users to go back or cancel, if they choose not to link. Use the wording "Cancel" for the cancel action.
  5. You must implement this workflow: After clicking "Agree and link", you must show linking success and redirect the user back to the Google Home app automatically. The user should now see the linked device on the Google Home app with your action. After clicking "Cancel" you should redirect the user back to the Google Home app.

Recommendations

We recommend that you do the following:

  1. Display Google's Privacy Policy. Include a link to Google's Privacy Policy on the consent screen.

  2. Data to be shared. Use clear and concise language to tell the user what data of theirs Google requires and why.

  3. Ability to unlink. Offer a mechanism for users to unlink, such as a URL to their account settings on your platform. Alternatively, you can include a link to Google Account where users can manage their linked account.

  4. Ability to change user account. Suggest a method for users to switch their account(s). This is especially beneficial if users tend to have multiple accounts.

    • If a user must close the consent screen to switch accounts, send a recoverable error to Google so the user can sign in to the desired account with OAuth linking and the implicit flow.
  5. Include your logo. Display your company logo on the consent screen. Use your style guidelines to place your logo. If you wish to also display Google's logo, see Logos and trademarks.

This figure shows an example consent screen with call-outs to the
            individual requirements and recommendations to be followed when
            you design a user consent screen.
Figure 1: Account linking consent screen design guidelines.

为基于 OAuth 的App Flip进行设置

以下部分介绍了基于 OAuth 的 App Flip 的前提条件,以及如何在 Actions 控制台中配置 App Flip 项目。

创建智能家居 Action 并设置 OAuth 2.0 服务器

您需要先执行以下操作,然后才能配置 App Flip

在 Actions 控制台中配置 App Flip

以下部分介绍了如何在 Actions 控制台中配置 App Flip

  1. 填写 OAuth Client information 下的所有字段。 (如果 App Flip 不受支持,则会使用常规 OAuth 作为后备选项。)
  2. Use your app for account linking(optional) 下,选中 Enable for iOS
  3. 填写 Universal Link 字段。如需详细了解通用链接,请参阅允许应用和网站链接到您的内容
  4. 如果你想选择配置客户端,请添加范围,然后点击 Configure your client (optional) 下的 Add scope
  5. 点击保存

现在,您可以继续学习下一部分,在您的 iOS 或 Android 应用中实现 App Flip

在原生应用中实现 App Flip

若要实现 App Flip,您需要修改应用中的用户授权代码,以接受来自 Google 的深层链接。

在您的设备上测试 App Flip

现在,您已经在控制台和应用中创建了一个 Action 并配置了 App Flip,接下来可以在移动设备上测试 App Flip 了。您可以使用 Google Assistant appGoogle Home app (GHA) 来测试 App Flip

如需测试 Google Assistant app 中的 App Flip,请按以下步骤操作:

  1. 转到 Actions 控制台并选择你的项目。
  2. 点击顶部导航栏中的 Test
  3. Google Assistant 应用中触发帐号关联流程:
    1. 打开 Google Assistant app
    2. 点击设置
    3. Assistant 标签页上,点击家居控制
    4. 点击“添加”(+)
    5. 从提供商列表中选择你的 Action。它在列表中以“[test]”为前缀。从列表中选择 [test] Action 后,就应该会打开你的应用。
    6. 验证你的应用是否已启动并开始测试授权流程。

如需从 Google Home 应用测试 App Flip,请按以下步骤操作:

  1. 转到 Actions 控制台并选择你的项目。
  2. 点击顶部导航栏中的 Test
  3. Home 应用中触发帐号关联流程:
    1. 打开 Google Home app (GHA)
    2. 点击 + 按钮。
    3. 点击设置设备
    4. 点击有已设置好的设备?
    5. 从提供商列表中选择您的 smart home Action。它在列表中以“[test]”为前缀。从列表中选择 [test] Action 后,就应该会打开你的应用。
    6. 验证你的应用是否已启动并开始测试授权流程。