次要使用者驗證

雙重使用者驗證可為語音指令新增雙重驗證安全防護。這項功能可為特定操作 (例如關閉監視攝影機或開門) 增加額外的安全防護措施。雙重使用者驗證不會與特定裝置特徵綁定,因此您可以決定何時讓 Google Assistant 發出驗證要求。舉例來說,你可以選擇針對監視攝影機的 OnOff 特徵發出驗證要求,但不能針對燈具的 OnOff 特徵發出驗證要求。您也可以在特定情況下,針對同一項動作Assistant 提出挑戰。舉例來說,如果 NFC 鑰匙圈不在門附近,您可以要求 Assistant 發出驗證要求來開門,但如果鑰匙圈在附近,則不發出驗證要求。

Assistant 可以發出兩種驗證要求:明確確認或個人識別碼 (PIN)。這會在從 Assistant 傳送回動作的 QUERYEXECUTE 意圖中新增驗證方塊,並接受 challengeNeeded 錯誤回應。Assistant 接著會將意圖要求連同驗證區塊中的驗證資料,傳回給動作。接著,您可以驗證驗證碼資料,判斷使用者是否提供正確的安全問題答案。

Assistant 會使用對話方塊發出驗證問題,但如果您在非語音途徑上使用 Assistant,系統會在畫面上顯示 PIN 碼和確認訊息。

雙重使用者驗證的使用時機

您可以為任何裝置類型或特徵啟用雙重使用者驗證。 不過,如要取得整合認證,您必須針對特定安全防護敏感的裝置類型和特徵,導入雙重使用者驗證。

使用pinNeeded驗證類型進行雙重使用者驗證,適用於以下特徵和裝置類型組合:

  • 如果裝置類型為 CAMERA,則為 OnOff 特徵。
  • 如果裝置類型為 DOORGARAGEGATEWINDOW,則為 OpenClose 特徵。
  • 解鎖時的 LockUnlock 特徵。
  • 解除武裝或取消解除武裝時的 ArmDisarm 特徵。
  • 如果裝置類型為 NETWORKROUTER,則為 RebootSoftwareUpdateNetworkControl 特徵。

如果裝置類型為 AC_UNIT,且整合位置在日本,則 TemperatureSetting 特徵需要 ackNeeded 挑戰類型。

支援的驗證類型

系統支援的雙重使用者驗證問題類型如下:

  • 沒有雙重使用者驗證 - 要求和回應未使用雙重使用者驗證。
  • 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 正在調暗客廳的燈。
要求 1
{
  "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
          }
        }]
      }]
    }
  }]
}
回覆 1
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [{
      "ids": ["123"],
      "status": "ERROR",
      "errorCode": "challengeNeeded",
      "challengeNeeded": {
        "type": "ackNeeded"
      }
    }]
  }
}
要求 2
{
  "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
          }
        }]
      }]
    }
  }]
}
回覆 2
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [{
      "ids": ["123"],
      "status": "SUCCESS"
    }]
  }
}

ackNeeded 與特徵狀態

次要使用者確認驗證,可使用特徵的狀態。舉例來說,如果您使用 TemperatureSetting 特徵,且同時設定 thermostatModethermostatTemperatureSetpointAssistant 可以詢問「你確定要將空調的溫度設為 28 度嗎?」

您也可以在回覆中加入狀態,讓 Assistant 根據指定要求執行特定動作。

下列特徵和狀態支援 ackNeeded,並提供特徵狀態。如果列出特定特徵,表示系統支援該特徵的所有狀態。

  • ArmDisarm
    • 使用 ackNeeded 驗證類型即可啟動或取消啟動裝置,但如要解除或取消解除,則必須使用 pinNeeded 驗證類型。
  • Fill
  • LockUnlock
    • 使用 ackNeeded 挑戰類型鎖定裝置,並使用 pinNeeded 挑戰類型解鎖。
  • OnOff
    • on
    • 請使用 ackNeeded 挑戰類型。如果將這項特徵與 CAMERA 裝置搭配使用,則必須提供 pinNeeded 驗證類型。
  • OpenClose
    • 請使用 ackNeeded 挑戰類型。搭配 DOORGARAGEGATEWINDOW 裝置使用這項特徵時,必須提供 pinNeeded 驗證類型。
  • Scene
  • TemperatureSetting
    • thermostatMode
    • thermostatTemperatureSetpoint
    • thermostatTemperatureSetpointHigh
    • thermostatTemperatureSetpointLow

這個範例顯示使用特徵狀態的 ackNeeded 挑戰要求和回應。將空調模式切換為暖氣,並將溫度設為 28 度。接著,Assistant 會要求使用者確認開啟暖氣並將溫度設為 28 度,因為回應中會傳回 thermostatTemperatureSetpoint28 狀態。

使用者 將空調模式設為暖氣。
Google Assistant 確定要將空調的暖氣設為 28 度嗎?
使用者 是。
Google Assistant 正在將空調的暖氣設為 28 度。
要求 1
{
  "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"
          }
        }]
      }]
    }
  }]
}
回覆 1
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [{
      "ids": ["123"],
      "status": "ERROR",
      "states": {
        "thermostatMode": "heat",
        "thermostatTemperatureSetpoint": 28
      },
      "errorCode": "challengeNeeded",
      "challengeNeeded": {
        "type": "ackNeeded"
      }
    }]
  }
}
要求 2
{
  "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
          }
        }]
      }]
    }
  }]
}
回覆 2
{
  "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

請參閱「錯誤和例外狀況」的完整清單。