應用程式翻轉

實作 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

  1. You must have a Google authorization statement such as "Once linked, Google will have permission to control your devices."
  2. 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.
  3. 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.
  4. 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.
  5. 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:

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

  4. 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.
  5. 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 1: Account linking consent screen design guidelines.

設定以 OAuth 為基礎的 App Flip

以下各節將說明 OAuth 型 App Flip 的先決條件,以及如何在 Google Home 開發人員控制台中設定 App Flip 專案。

建立雲端對雲端整合並設定 OAuth 2.0 伺服器

如要設定 App Flip,您必須先完成下列步驟:

在開發人員控制台中設定應用程式翻轉功能

以下說明如何在 開發人員控制台中設定 App Flip。

  1. 填寫「OAuth 用戶端資訊」下方的所有欄位。 (如果不支援 App Flip,系統會使用一般 OAuth 做為備用方案)。
  2. 在「使用您的應用程式進行帳戶連結」(選用) 下方,勾選「針對 iOS 啟用」
  3. 填寫「通用連結」欄位。如要進一步瞭解通用連結,請參閱「允許應用程式和網站連結至您的內容」。
  4. 如果您想選擇性設定用戶端,請新增範圍,然後按一下「Configure your client (optional)」下方的「Add scope」
  5. 按一下 [儲存]

您現在可以繼續閱讀下一節,瞭解如何在 iOS 或 Android 應用程式中實作 App Flip

在原生應用程式中導入 App Flip

如要實作 App Flip,您必須修改應用程式中的使用者授權碼,以便接受 Google 提供的深層連結。

在裝置上測試 App Flip

您已建立雲端到雲端整合,並在控制台和應用程式中設定 App Flip,現在可以透過行動裝置測試 App Flip。您可以使用 Google Home 應用程式測試 App Flip。

如要從 Google Home 應用程式測試 App Flip,請按照下列步驟操作:

  1. 前往 Developer Console,然後選取您的專案。
  2. 依序前往「雲端到雲端」>「測試」
  3. 透過 Google Home 應用程式觸發帳戶連結流程:
    1. 開啟 Google Home app (GHA)
    2. 按一下「+」按鈕。
    3. 按一下「設定裝置」
    4. 按一下「是否有已經設定好的裝置?」
    5. 從供應商清單中選取雲端到雲端整合服務。在清單中,這項測試會在名稱前加上「[test]」。從清單中選取 [test] 整合後,應用程式應會開啟。
    6. 確認應用程式已啟動,並開始測試授權流程。