帳戶連結

每個 smart home 動作都必須包含驗證使用者的機制。

可以透過驗證功能將使用者的 Google 帳戶連結至驗證系統中的使用者帳號。這可讓您在執行要求收到智慧型住宅意圖時識別使用者。Google 智慧型住宅僅支援具備授權碼流程的 OAuth。

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

OAuth

smart home 來說,您必須透過 OAuth 使用授權代碼流程,這需要您有兩個端點:授權權杖交換端點。

在您驗證使用者之後,當 smart home 意圖傳送至執行要求時,使用者的第三方 OAuth 2.0 存取權杖會在授權標頭中傳送。所有使用者都必須執行帳戶連結作業,因為裝置資訊會透過 action.devices.SYNC 意圖傳送至 Google Assistant,藉此要求帳戶連結。

您的 smart home 動作應支援連結同一個使用者帳戶的多位 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