Google Account 連結與 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.

設計指南

本節說明 AppFlip 帳戶連結同意畫面的畫面設計規定和建議。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 應用程式的 App Flip 功能,請按照 Android 導入指南中的說明操作。

如要支援 iOS 應用程式的 App Flip 功能,請按照 iOS 導入指南中的說明操作。

測試應用程式翻轉

在可以使用通過驗證的正式版應用程式和有效的 OAuth 2.0 伺服器之前,系統可能會先使用範例和測試應用程式模擬應用程式翻轉功能。

在應用程式翻轉期間,Google 應用程式會先開啟應用程式,接著在 OAuth 2.0 伺服器上要求授權碼回應,最後一步則將回應傳回至 Google 應用程式。

必要條件

如要模擬 Google 應用程式並觸發會啟動應用程式的意圖,請下載並安裝 AndroidiOS 應用程式翻轉應用程式測試工具。

下載並安裝 Android 版和 iOS 版應用程式翻轉範例,如要模擬應用程式並選取 OAuth 2.0 回應類型。

測試順序

  1. 開啟應用程式翻轉測試工具。
  2. 按下 Try Flip! 即可啟動 App Flip 範例應用程式。
  3. 從「範例應用程式」的圓形按鈕中選取回應。
  4. Send 即可將模擬 OAuth 2.0 回應傳回測試工具。
  5. 查看測試工具的記錄訊息,確認是否有 auth_code 或錯誤詳細資料。

正式版測試

完成註冊和 OAuth 2.0 伺服器實作後,即可在實際工作環境中測試應用程式翻轉功能。

建議您使用單一 Google 帳戶和工作專屬的電子郵件地址來自動測試。

以 Google 帳戶持有人身分登入時,您可以使用已連結帳戶查看帳戶連結狀態。您也可以在這些帳號中,反覆測試不同帳戶。

您也可以選擇實作 RISC,透過程式取消連結並通知 Google。