借助基于 OAuth 的应用快速关联 (App Flip),您的用户可以轻松快速地将其在您的身份验证系统中的账号与其 Google 账号相关联。如果用户在发起账号关联流程时您的应用已安装在其手机上,系统会将用户顺畅地转到您的应用以获取用户授权。
这种方法可简化关联流程,因为用户无需重新输入用户名和密码即可进行身份验证;相反,App Flip 会利用用户在您应用中的账号凭据。用户将其 Google 账号与您的应用相关联后,便可使用您开发的任何集成。
您可以为 iOS 和 Android 应用设置应用快速关联。
要求
如需实现应用翻转,您必须满足以下要求:
- 您必须拥有 Android 或 iOS 应用。
- 您必须拥有、管理和维护一个支持 OAuth 2.0 授权代码流程的 OAuth 2.0 服务器。
For more information on the OAuth linking authorization code flow, see Implement your OAuth server.
设计准则
本部分介绍了 App Flip 账号关联意见征求界面的设计要求和建议。Google 调用您的应用后,应用会向用户显示同意屏幕。
要求
- 您必须说明用户的账号将与 Google 相关联,而不是与特定 Google 产品(例如 Google Home 或 Google 助理)相关联。
建议
建议您执行以下操作:
显示 Google 的隐私权政策。在同意屏幕上添加指向 Google 隐私权政策的链接。
要分享的数据。使用简洁明了的语言告知用户 Google 需要哪些数据以及为何需要这些数据。
明确的号召性用语。在用户同意页面上提供明确的号召性用语,例如“同意并关联”。这是因为用户需要了解他们需要与 Google 分享哪些数据才能关联账号。
能够取消。为用户提供返回或取消链接的途径,如果用户选择不进行关联。
能够解除关联。提供一种供用户解除关联的机制,例如指向他们在您的平台上账号设置的网址。或者,您也可以添加指向 Google 账号的链接,以便用户管理其关联的账号。
能够更改用户账号。建议用户切换账号的方法。如果用户通常拥有多个账号,这种做法尤为有益。
- 如果用户必须关闭意见征求界面才能切换账号,请向 Google 发送可恢复的错误,以便用户可以使用 OAuth 关联和隐式流程登录所需的账号。
添加您的徽标。在同意屏幕上显示您的公司徽标。 按照您的样式准则放置徽标。如果您还想显示 Google 的徽标,请参阅徽标和商标。
Set up for OAuth-based App Flip
The following sections describe the prerequisites for OAuth-based App Flip and how to configure your App Flip project in the Actions console.
Create an Action and set up an OAuth 2.0 server
Before you can configure App Flip, you need to do the following:
- Create an Action. To create an Action, follow the instructions in the Create a project section.
- Set up an OAuth 2.0 server. For more information about setting up an OAuth server, see Implement OAuth account linking.
Configure App Flip in the Actions console
The following section describes how to configure App Flip in the Actions console.
- Click Develop in the top navigation. Then, click Account linking in the left navigation.
- Toggle on the switch next to Account linking.
- Under Account creation, select No, I only want to allow account creation on my website.
- Click Next.
- Under Linking type, select OAuth and Authorization code from the drop-down menus.
- Click Next.
- Fill out all the fields under OAuth Client information. (If App Flip isn’t supported, regular OAuth is used as a fallback.)
- Click Next.
- Under Use your app for account linking (optional), check Enable for iOS.
- Fill out the Universal Link field. For more information about universal links, see Allowing Apps and Websites to Link to your Content .
- If you want to optionally configure your client, add scopes and click Add scope under Configure your client (optional). If not, click Next.
- Under Testing instructions, type
test
(or any other string) as a placeholder. (Filling in this field with a test account is only necessary if you are actually submitting your Action to be published.) - Click Save.
You can now continue to the next section to implement App Flip in your iOS or Android app.
Implement App Flip in your native apps
To implement App Flip, you need to modify the user authorization code in your app to accept a deep link from Google.
Test App Flip on your device
Now that you’ve created an Action and configured App Flip on the console and in your app, you can test App Flip on your mobile device. You can use the Google Assistant app to test App Flip.
To test App Flip from the Assistant app, follow these steps:
- Go to the Actions console and select your project.
- Click Test in the top navigation.
- Trigger the account linking flow from the Assistant app:
- Open the Google Assistant app.
- Click Settings.
- On the Assistant tab, click Home Control.
- Click Add(+).
- Select your Action from the list of providers. It will be prefixed with “[test]” in the list. When you select your [test] Action from the list, it should open your app.
- Verify that your app was launched and begin testing your authorization flow.