帳戶連結

每個 Cloud-to-cloud 整合都必須包含使用者驗證機制。

驗證可讓您將使用者的 Google 帳戶連結至驗證系統中的使用者帳戶。這樣一來,當智慧住宅服務收到意圖時,您就能識別使用者。Google 智慧住宅僅支援使用授權碼流程的 OAuth。

實作 OAuth 2.0 後,您可以選擇設定以 OAuth 為基礎的 App Flip,讓使用者更快速地將驗證系統中的帳戶連結至 Google 帳戶。

OAuth

如要使用 smart home,您必須使用 OAuth 搭配授權碼流程,這需要兩個端點:授權權杖交換端點。

驗證使用者身分後,系統會將使用者的第三方 OAuth 2.0 存取權杖傳送至授權標頭,然後將 smart home 意圖傳送至你的執行服務。所有使用者都必須連結帳戶,因為裝置資訊會透過 action.devices.SYNC 意圖傳送至 Google Assistant,而這需要連結帳戶。

Cloud-to-cloud整合功能應支援多位 Google 使用者連結至同一使用者帳戶 (例如,使用者授予家中其他使用者存取權時)。如果服務無法支援多個使用者連線,應在帳戶連結時提供錯誤訊息。

如需如何為整合服務設定 OAuth 2.0 伺服器的操作說明,請參閱「實作 OAuth 2.0 伺服器」。

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

如要進一步瞭解 OAuth 連結授權碼流程,請參閱「實作 OAuth 2.0 伺服器」。

如要瞭解如何為整合服務設定 App Flip,請參閱「OAuth 型 App Flip」。