雙重使用者驗證可為語音指令新增雙重驗證安全防護。這項功能可為特定操作 (例如關閉安全攝影機或開門) 增加額外安全防護。雙重使用者驗證不會與特定裝置特徵綁定,因此您可以決定何時讓 Google Assistant 發出驗證要求。舉例來說,您可以選擇對安全攝影機的 OnOff 特徵發出驗證要求,但對燈具的 OnOff 特徵則不發出驗證要求。您也可以在特定情況下,針對同一項動作Assistant 提出挑戰。舉例來說,如果 NFC 鑰匙圈不在門附近,您可以要求 Assistant 發出驗證要求來開門,但如果鑰匙圈在附近,則不發出驗證要求。
Assistant 可以發出兩種驗證要求:明確確認或個人識別碼 (PIN)。這會在從 Assistant 傳送回動作的 QUERY
和 EXECUTE
意圖中新增驗證方塊,並接受 challengeNeeded
錯誤回應。Assistant 接著會將意圖要求連同驗證區塊中的驗證資料傳回給動作。接著,您可以驗證驗證碼資料,判斷使用者是否提供正確的安全問題答案。
Assistant 會使用對話方塊發出驗證要求,但如果您在非語音介面上使用 Assistant,系統會在畫面上顯示 PIN 碼和確認訊息。
支援的裝置類型
所有類型的裝置都支援雙重使用者驗證。
支援的裝置特徵
所有裝置特徵都支援雙重使用者驗證。
支援的驗證類型
系統支援的雙重使用者驗證身分確認問題類型如下:
- 無驗證問題 - 要求和回應未使用次要使用者驗證問題。
- ackNeeded - 需要明確確認 (是或否) 的二次使用者驗證,也可以使用特徵狀態做為回應意見回饋。安全裝置和特徵不建議使用這類驗證問題。
- pinNeeded - 需要個人識別碼 (PIN 碼) 的次要使用者驗證,適用於安全裝置和特徵。
沒有挑戰
這個範例顯示成功的 EXECUTE
要求和回應,沒有開啟燈光的驗證程序。
使用者 | 開燈。 |
Google Assistant | 好的,正在開啟 3 盞燈。 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.OnOff", "params": { "on": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "SUCCESS", "states": { "on": true, "online": true } }] } }
ackNeeded
次要使用者確認驗證,可使用特徵的多種狀態或簡單的確認驗證。
ackNeeded
挑戰類型如下:
ackNeeded simple
這個範例顯示簡單的要求和回應,其中包含調暗燈光的 ackNeeded
挑戰,以及調暗燈光的確認訊息。
使用者 | 調暗客廳的燈。 |
Google Assistant | 正在調暗客廳的燈。您確定嗎? |
使用者 | 是。 |
Google Assistant | 正在調暗客廳的燈。 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.BrightnessAbsolute", "params": { "brightness": 12 } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "ackNeeded" } }] } }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.BrightnessAbsolute", "params": { "brightness": 12 }, "challenge": { "ack": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "SUCCESS" }] } }
ackNeeded 與特徵狀態
次要使用者確認驗證,可使用特徵的狀態。舉例來說,如果您使用 TemperatureSetting 特徵,且同時設定 thermostatMode
和 thermostatTemperatureSetpoint
,Assistant 可以詢問「你確定要將空調的溫度設為 28 度嗎?」
您也可以在回應中加入狀態,讓 Assistant 根據指定要求執行特定動作。
下列特徵和狀態支援 ackNeeded
,並提供特徵狀態。如果列出特定特徵,表示支援該特徵的所有狀態。
- ArmDisarm
currentArmLevel
currentStatusReport
- Fill
- LockUnlock
- OnOff
on
- OpenClose
- Scene
- TemperatureSetting
thermostatMode
thermostatTemperatureSetpoint
thermostatTemperatureSetpointHigh
thermostatTemperatureSetpointLow
這個範例顯示要求和回應,其中包含使用特徵狀態的 ackNeeded
驗證。將空調模式切換為暖氣,並將溫度設為 28 度。接著,Assistant 會要求使用者確認開啟暖氣,並將溫度設為 28 度,因為回應中會傳回 thermostatTemperatureSetpoint
的 28
狀態。
使用者 | 將空調模式設為暖氣。 |
Google Assistant | 確定要將空調的暖氣設為 28 度嗎? |
使用者 | 是。 |
Google Assistant | 正在將空調的暖氣設為 28 度。 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.TemperatureSetting", "params": { "thermostatMode": "heat" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "ERROR", "states": { "thermostatMode": "heat", "thermostatTemperatureSetpoint": 28 }, "errorCode": "challengeNeeded", "challengeNeeded": { "type": "ackNeeded" } }] } }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.TemperatureSetting", "params": { "thermostatMode": "heat" }, "challenge": { "ack": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "SUCCESS", "states": { "thermostatMode": "heat", "thermostatTemperatureSetpoint": 28 } }] } }
pinNeeded
建議安全裝置使用pinNeeded
挑戰。
這個範例顯示初始要求和回應,其中包含 pinNeeded
驗證。這個範例會傳回含有 pinNeeded
驗證問題的回應,因此 Assistant 會要求輸入 PIN 碼。此時使用者可以提供正確或錯誤的 PIN 碼。
錯誤或有效 PIN 碼的要求和回應範例:
使用者 | 將門解鎖。 |
Google Assistant | 可以告訴我你的安全碼嗎? |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.LockUnlock", "params": { "lock": false } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "pinNeeded" } }] } }
PIN 不正確
這個範例顯示要求和回應,以及 challengeFailedPinNeeded
驗證問題。如果初始 pinNeeded
驗證失敗,請使用這項驗證。
如果傳回 challengeFailedPinNeeded
型別,Assistant 會再次要求提供安全碼。如果使用者嘗試失敗次數過多,您可以傳回 tooManyFailedAttempts
錯誤回應。請參閱「錯誤回應」。
使用者 | 333222 |
Google Assistant | 抱歉,安全碼有誤。 可以告訴我你的安全碼嗎? |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.LockUnlock", "params": { "lock": false }, "challenge": { "pin": "333222" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "challengeFailedPinNeeded" } }] } }
有效 PIN 碼
以下範例顯示有效 PIN 碼的要求和回應。
使用者 | 333444 |
Google Assistant | 正在解鎖門鎖。 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.LockUnlock", "params": { "lock": false }, "challenge": { "pin": "333444" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "SUCCESS", "states": { "isLocked": false, "isJammed": false } }] } }
使用者 | 調暗客廳的燈。 |
Google Assistant | 可以告訴我你的安全碼嗎? |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.BrightnessAbsolute", "params": { "brightness": 12 } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["123"], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "pinNeeded" } }] } }
錯誤回應
以下是回應中可能會傳回的錯誤代碼:
- tooManyFailedAttempts - 嘗試失敗次數過多,請稍後再試。 請使用裝置上的應用程式完成這項動作。
- pinIncorrect - 抱歉,安全碼有誤。
- userCancelled - Ok
請參閱錯誤和例外狀況的完整清單。