概览

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 服务器

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 communicate that the user’s account is being linked to Google, not to a specific Google product, such as Google Home or Google Assistant.

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. Clear call-to-action. State a clear call-to-action on your consent screen, such as “Agree and link.” This is because users need to understand what data they're required to share with Google to link their accounts.

  4. Ability to cancel. Provide a way for users to go back or cancel, if they choose not to link.

  5. 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.

  6. 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.
  7. 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 2. Account linking consent screen design guidelines.

基于 OAuth 的应用快速关联的设置

以下部分描述了基于 OAuth 的应用快速关联的前提条件,以及如何在 Actions 控制台中配置应用快速关联项目。

创建 Action 并设置 OAuth 2.0 服务器

如需配置应用快速关联,你需要先执行以下操作:

  • 创建 Action。如需创建 Action,请按照创建项目部分中的说明操作。
  • 设置 OAuth 2.0 服务器。如需详细了解如何设置 OAuth 服务器,请参阅实现 OAuth 帐号关联

在 Actions 控制台中配置应用快速关联

以下部分介绍了如何在 Actions 控制台中配置应用快速关联。

  1. 点击顶部导航栏中的 Develop。然后,点击左侧导航栏中的 Account linking
  2. 开启帐号关联旁边的开关。
  3. 帐号创建下,选择不,我只想允许在我的网站上创建帐号
  4. 点击下一步
  5. 关联类型下,从下拉菜单中选择 OAuth授权代码
  6. 点击 Next
  7. 填写 OAuth Client information 下的所有字段。(如果不支持 App Flip,则会使用常规 OAuth 作为后备选项。)
  8. 点击下一步
  9. Use your app for account linking (optional) 下方,选中 Enable for iOS
  10. 填写 Universal Link 字段。如需详细了解通用链接,请参阅允许应用和网站链接到您的内容
  11. 如果您想视情况配置客户端,请添加范围,然后点击 Configure your client (optional) 下的 Add scope。 如果没有,请点击下一步
  12. 在“测试说明”下,输入 test(或任何其他字符串)作为占位符。(只有在您实际提交要发布的 Action 时,才需要使用测试账号填写此字段。)
  13. 点击保存

现在,你可以继续阅读下一部分,了解如何在 iOS 或 Android 应用中实现应用快速关联功能。

在原生应用中实现应用快速关联

如需实现应用快速关联功能,你需要修改应用中的用户授权代码,以接受来自 Google 的深层链接。

在设备上测试应用快速关联

现在,你已在控制台和应用中创建了一个 Action 并配置了应用快速关联,接下来可以在移动设备上测试应用快速关联。你可以使用 Google 助理应用测试 App Flip。

如需从 Google 助理应用测试应用快速关联,请按以下步骤操作:

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