概要

借助基于 OAuth 的应用快速关联(应用快速关联),您的用户可以轻松地将其在身份验证系统中的帐号关联到其 Google 帐号。如果您的应用在用户启动帐号关联流程时安装在用户手机上,则可以无缝同步到您的应用以获取用户授权。

此方法可让用户更快、更轻松地完成关联流程,因为用户无需重新输入用户名和密码进行身份验证;而应用快速关联可利用您应用中的用户帐号的凭据。用户将其 Google 帐号与您的应用关联后,他们即可利用您开发的任何集成。

您可以为 iOS 和 Android 应用设置应用快速关联。

此图显示了用户将其 Google 帐号与身份验证系统关联的步骤。第一张屏幕截图显示了在用户的 Google 帐号与您的应用相关联的情况下,用户如何选择您的应用。第二张屏幕截图显示了将 Google 帐号与应用相关联的确认信息。第三张屏幕截图显示了 Google 应用中已成功关联的用户帐号。
图 1.使用应用快速关联功能在用户的手机上关联帐号。

要求

如需实现应用快速关联,您必须满足以下要求:

  • 您必须拥有 Android 或 iOS 应用。
  • 您必须拥有、管理和维护支持 OAuth 2.0 授权代码流的 OAuth 2.0 服务器。

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 Console で設定する方法について説明します。

アクションを作成して OAuth 2.0 サーバーを設定する

アプリ切り替えを設定する前に、以下を行う必要があります。

Actions Console でアプリ切り替えを設定する

次のセクションでは、Actions Console でアプリ切り替えを構成する方法を説明します。

  1. 上部のナビゲーションにある [Develop](開発)をクリックし、次に、左側のナビゲーションで [アカウントのリンク] をクリックします。
  2. [アカウントのリンク] の横にあるスイッチをオンに切り替えます。
  3. [Account creation] で、[No, I only want to allow account creation on my website] を選択します。
  4. [次へ] をクリックします。
  5. [リンクタイプ] で、プルダウン メニューから [OAuth] と [認可コード] を選択します。
  6. [Next] をクリックします。
  7. [OAuth クライアント情報] の下にあるすべてのフィールドに入力します。(アプリ切り替えがサポートされていない場合は、通常の OAuth がフォールバックとして使用されます)。
  8. [次へ] をクリックします。
  9. [アプリでのアカウントのリンク(省略可)] で [iOS で有効にする] をオンにします。
  10. [Universal Link](ユニバーサル リンク)フィールドに入力します。ユニバーサル リンクについて詳しくは、アプリとウェブサイトのコンテンツへのリンクを許可する をご覧ください。
  11. 必要に応じてクライアントを構成する場合は、スコープを追加して、[Configure your client (optional)](クライアントの構成(省略可))で [Addscope](スコープを追加)をクリックします。そうでない場合は、[次へ] をクリックします。
  12. [テスト手順] で、プレースホルダとして「test」などの文字列を入力します。(このフィールドにテスト アカウントを入力する必要があるのは、公開するアクションを実際に送信する場合のみです)。
  13. [保存] をクリックします。

次のセクションに進んで iOS アプリまたは Android アプリにアプリ切り替えを実装できます。

ネイティブ アプリにアプリ切り替えを実装する

アプリ切り替えを実装するには、Google からのディープリンクを許可するようにアプリのユーザー認可コードを変更する必要があります。

デバイスでアプリ切り替えをテストする

アクションを作成し、コンソールとアプリでアプリ切り替えを設定したら、モバイル デバイスでアプリ切り替えをテストできます。アプリ切り替えのテストには Google アシスタント アプリを使用できます。

アシスタント アプリからアプリ切り替えをテストする手順は次のとおりです。

  1. Actions Console に移動して、プロジェクトを選択します。
  2. 上部のナビゲーションで [Test](テスト)をクリックします。
  3. アシスタント アプリからアカウントのリンクフローをトリガーします。
    1. Google アシスタント アプリを起動します。
    2. [設定] をクリックします。
    3. [アシスタント] タブで、[スマートホーム] をクリックします。
    4. [追加(+)] をクリックします。
    5. プロバイダのリストからアクションを選択します。リストの先頭に「[test]」が付きます。リストから [test] アクションを選択する場合、アプリを開く必要があります。
    6. アプリが起動したことを確認し、承認フローのテストを開始します。