次要使用者驗證可讓您為語音指令新增雙重安全性。這可讓您針對特定動作 (例如關閉監視攝影機或開啟車門) 提供額外的安全防護。次要使用者驗證未綁定特定裝置特徵,可讓您決定何時啟用 Google Assistant issue a challenge. For example, you can choose to issue a challenge for the OnOff trait for a security camera, but not issue a challenge for the OnOff trait for a light. You can also have Assistant issue challenges in certain situations for the same action. For example, you can request that Assistant issue a challenge request to open a door if an NFC keyfob is not in the proximity of that door, but not issue a challenge if the keyfob is present.
Assistant 可發出兩種類型的挑戰:明確確認或個人識別碼 (PIN 碼)。這會將驗證區塊新增至從 Assistant 回傳的 QUERY
和 EXECUTE
意圖,並傳回 challengeNeeded
錯誤回應。接著,Assistant 將挑戰要求傳回挑戰區塊中的驗證資料。接著,您可以驗證驗證資料,判斷使用者是否已提供正確的安全性回應。
Assistant 使用對話方塊發出挑戰,但如果您在非語音介面上使用 Assistant,可在螢幕上完成 PIN 碼和確認程序。
支援的裝置類型
所有裝置類型都支援次要使用者驗證。
支援的裝置特性
所有裝置特性都支援次要使用者驗證。
支援的驗證類型
系統支援的次要使用者驗證驗證類型如下:
- 無驗證 - 未使用次要使用者驗證驗證的要求和回應。
- ackneeded - 需要明確確認 (是或否) 的次要使用者驗證,也可以利用特性狀態做為回應意見回饋。我們不建議在安全性裝置和特性中使用這種驗證類型。
- pinRequireed - 需要使用者個人識別號碼 (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
的挑戰類型如下:
ackacked 簡單
此範例顯示簡單的要求和回應,其中包含 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" }] } }
ackited 與特性
可使用使用者狀態的次要使用者確認驗證。舉例來說,如果您使用的是 TemperatureSetting 特性,且 thermostatMode
和 thermostatTemperatureSetpoint
都設定了,Assistant 可以詢問您確定要將空調設為 28 度的溫度嗎?
您也可以在回應中加入狀態,讓 Assistant 根據特定要求執行特定動作。
下列特性和狀態支援具有特性特性的 ackNeeded
。特定特性的清單表示支援所有狀態。
- ArmDisarm
currentArmLevel
currentStatusReport
- 填滿
- LockLock
- 開啟
on
- OpenClose
- 場景
- 溫度設定
thermostatMode
thermostatTemperatureSetpoint
thermostatTemperatureSetpointHigh
thermostatTemperatureSetpointLow
此範例顯示使用指定特性的 ackNeeded
驗證的要求與回應。因此會將空調模式切換成暖氣模式,並將溫度設為 28 度。接著,Assistant 會要求使用者確認啟用熱能,並將溫度設為 28 度,因為 28
的 thermostatTemperatureSetpoint
會在回應中傳回狀態。
使用者 | 將空調模式設為暖氣。 |
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 } }] } }
需要 PIN
建議在安全性裝置上採用 pinNeeded
驗證問題。
此示例顯示初始要求和回應帶有 pinNeeded
挑戰。此範例會傳回有 pinNeeded
挑戰的回應,因此 Assistant 會要求圖釘。此時,使用者可以提供不正確或有效的 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" } }] } }
錯誤回應
您的回應可以傳回以下一些錯誤代碼:
challengeFailedNotSetup
- 這項操作需要安全碼,但您尚未在裝置的應用程式中設定。tooManyFailedAttempts
- 很抱歉,嘗試失敗次數過多,請前往裝置的應用程式完成相關操作。pinIncorrect
- 很抱歉,安全碼不正確。userCancelled
- 確定。
請參閱錯誤和例外狀況的完整清單。