拥有 OAuth 2.0 实现后,您可以选择配置基于 OAuth 的 App Flip,这可让您的 Android 用户更快地将其在您的身份验证系统中的账号关联到他们的 Google 账号。以下部分介绍了如何为 Cloud-to-cloud 集成设计和实现 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
- You must have a Google authorization statement such as "Once linked, Google will have permission to control your devices."
- 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.
- 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.
- 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.
- 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:
Display Google's Privacy Policy. Include a link to Google's Privacy Policy on the consent screen.
Data to be shared. Use clear and concise language to tell the user what data of theirs Google requires and why.
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.
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.
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.
基于 OAuth 的 App Flip 的设置
以下部分介绍了基于 OAuth 的 App Flip 的前提条件,以及如何在 Google Home 开发者控制台中配置 App Flip 项目。
创建云到云集成并设置 OAuth 2.0 服务器
在配置 App Flip 之前,您需要先执行以下操作:
- 设置 OAuth 2.0 服务器。如需详细了解如何设置 OAuth 服务器,请参阅实现 OAuth 2.0 服务器。
- 创建云到云集成。如需创建集成,请按照创建云到云集成中的说明操作。
在 Play 管理中心内配置 App Flip
以下部分介绍了如何在 Developer 控制台中配置 App Flip。
- 填写 OAuth Client information 下的所有字段。 (如果不支持 App Flip,则会使用常规 OAuth 作为后备选项。)
- 在 Use your app for account linking(optional) 下,选中 Enable for iOS。
- 填写 Universal Link 字段。如需详细了解通用链接,请参阅允许应用和网站链接到您的内容。
- 如果你想选择配置客户端,请添加范围,然后点击 Configure your client (optional) 下的 Add scope。
- 点击保存。
现在,您可以继续阅读下一部分,了解如何在 iOS 或 Android 应用中实现 App Flip。
在原生应用中实现 App Flip
如需实现 App Flip,您需要修改应用中的用户授权代码,以接受来自 Google 的深层链接。
在设备上测试 App Flip
现在,您已在控制台和应用中创建了云到云集成并配置了应用快速关联,接下来可以在移动设备上测试应用快速关联。您可以使用 Google Home 应用测试应用快速关联。
如需通过 Google Home 应用测试 App Flip,请按以下步骤操作:
- 前往 Developers Console 并选择您的项目。
- 依次选择云到云 > 测试。
- 在 Google Home 应用中触发账号关联流程:
- 打开 Google Home app (GHA)。
- 点击 + 按钮。
- 点击设置设备。
- 点击有已设置好的设备?
- 从提供商列表中选择您的云到云集成。它在列表中以“[test]”为前缀。从列表中选择 [test] 集成后,就应该会打开您的应用。
- 验证你的应用是否已启动并开始测试授权流程。