Google 帐号关联(基于 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.

设计准则

本部分介绍了应用快速关联帐号关联同意屏幕的设计要求和建议。Google 调用您的应用后,应用会向用户显示同意屏幕。

要求

  1. 您必须告知用户用户帐号正在与 Google 关联,而不是与特定 Google 产品(例如 Google Home 或 Google 助理)关联。

建议

建议您执行以下操作:

  1. 显示 Google 的隐私权政策。在同意屏幕上添加指向 Google 隐私权政策的链接。

  2. 要共享的数据。使用简洁明了的语言向用户说明他们的 Google 需要哪些数据以及为何收集这些数据。

  3. 明确的号召性用语。在同意屏幕上提供明确的号召性用语,例如“同意并关联”。这是因为用户需要了解他们需要与 Google 共享哪些数据,才能关联帐号。

  4. 能够取消。如果用户不关联,则可以提供返回或取消的方式。

  5. 能够解除关联。为用户提供解除关联的机制,例如他们在平台上的帐号设置网址。或者,您也可以添加指向 Google 帐号的链接,以便用户可以管理关联的帐号。

  6. 能够更改用户帐号。推荐一种供用户切换帐号的方法。如果用户往往拥有多个帐号,这一点尤其有用。

    • 如果用户必须关闭同意屏幕才能切换帐号,请向 Google 发送一个可恢复错误,以便用户通过 OAuth 关联隐式流程登录所需帐号。
  7. 添加徽标。在同意屏幕上显示公司徽标。 根据样式指南放置徽标。如果您还希望显示 Google 的徽标,请参阅徽标和商标

下图所示为同意屏幕的示例,其中展示了在设计用户同意屏幕时要遵循的各项要求和建议。
图 2.帐号关联同意屏幕设计准则。

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

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

如需在 Android 应用上支持应用快速关联,请按照 Android 实现指南中的说明操作。

如需在 iOS 应用中支持应用快速关联功能,请按照 iOS 实现指南中的说明操作。

测试应用快速关联

在获得正式生产应用之前,可以使用示例应用和模拟应用来模拟应用快速关联。

在应用快速关联期间,Google 应用会先打开您的应用,然后由 OAuth 2.0 服务器请求授权代码响应,然后在最后一步中将该响应返回给 Google 应用。

前提条件

如需模拟 Google 应用并触发用于启动应用的 intent,请下载并安装适用于 AndroidiOS 的应用快速关联测试工具。

下载并安装适用于 AndroidiOS 的应用快速关联示例。要模拟您的应用,请选择 OAuth 2.0 响应类型。

测试序列

  1. 打开应用快速关联测试工具。
  2. Try Flip! 可启动应用快速关联示例应用。
  3. 从示例应用的单选按钮中选择响应。
  4. Send 将模拟 OAuth 2.0 响应返回给测试工具。
  5. 查看测试工具日志消息,了解 auth_code 或错误详情。

生产测试

完成注册和 OAuth 2.0 服务器实现后,应用快速测试可能会在生产中进行测试。

建议使用单个 Google 帐号和特定于任务的电子邮件地址进行自动测试。

以 Google 帐号持有者身份登录时,可以使用关联的帐号查看帐号关联状态。也可以在此处取消重复测试的帐号之间的关联。

(可选)您可以选择实现 RISC,以便以编程方式解除这项变更并通知 Google。