Overview

Every smart home Action must include a mechanism for authenticating users.

Authentication allows you to link your users' Google accounts with user accounts in your authentication system. This allows you to identify your users when your fulfillment receives a smart home intent. Google smart home only supports OAuth with an authorization code flow.

Once you have an OAuth 2.0 implementation, you can optionally configure OAuth-based App Flip, which allows your users to more quickly link their accounts in your authentication system to their Google accounts.

OAuth

For smart home, you must use OAuth with an authorization code flow, which requires you to have two endpoints: the authorization and token exchange endpoints.

When you have authenticated a user, the user's third-party OAuth 2.0 access token is sent in the authorization header when smart home intents are sent to your fulfillment. All users have to perform account linking, because device information is sent to the Assistant with the action.devices.SYNC intent, which requires account linking.

Your smart home Action is expected to support multiple Google users connecting to the same user account (for example, when users give access to other users in their household). If your service can't support multiple user connections, it should provide errors at account linking time.

For instructions on how to set up an OAuth 2.0 server for your Action, see Implement your OAuth 2.0 server.

OAuth-based App Flip

基於OAuth的App Flip鏈接(App Flip)使您的用戶可以輕鬆快速地將其身份驗證系統中的帳戶鏈接到其Google帳戶。如果您的應用程序在用戶啟動帳戶鏈接過程時已安裝在用戶的手機上,則會無縫切換到您的應用程序以獲取用戶授權。

由於用戶不必重新輸入其用戶名和密碼進行身份驗證,因此該方法提供了更快,更輕鬆的鏈接過程。相反,App Flip會利用您應用程序中用戶帳戶的憑據。用戶將其Google帳戶與您的應用程序關聯後,他們就可以利用您開發的任何集成功能。

您可以同時為iOS和Android應用設置“應用翻轉”。

此圖顯示了用戶將其Google帳戶鏈接到您的身份驗證系統的步驟。第一個屏幕截圖顯示瞭如果用戶的Google帳戶已鏈接到您的應用程序,則該用戶如何選擇您的應用程序。第二張屏幕截圖顯示了將其Google帳戶與您的應用程序關聯的確認信息。第三個屏幕截圖顯示了Google應用程序中已成功鏈接的用戶帳戶。
圖1.使用App Flip在用戶電話上關聯帳戶。

要求

要實施應用翻轉,您必須滿足以下要求:

  • 您必須具有Android或iOS應用。
  • 您必須擁有,管理和維護支持OAuth 2.0授權代碼流的OAuth 2.0服務器。

For more information on the OAuth linking authorization code flow, see Implement your OAuth 2.0 server.

For instructions on how to configure App Flip for your Action, see OAuth-based App Flip.