傳送至對話 Webhook 的要求會以標頭中的授權權杖簽署,格式如下:
google-assistant-signature: "<JWT token>"
驗證權杖符合 JSON Web Token 格式,其中目標對象欄位值與應用程式的 Actions 主控台專案 ID 相同。如要驗證簽章,請解密權杖,並確認目標對象欄位與應用程式的專案 ID 相符。您可以使用與 JWT 相容的憑證庫 (例如 Google API Node.js 用戶端) 或以下動作 (使用 Actions on Google Node.js 程式碼範例) ConversationOptions#verification
const {conversation} = require('@assistant/conversation'); const app = conversation({verification: 'nodejs-cloud-test-project-1234'}); // HTTP Code 403 will be thrown by default on verification error per request.
JWT 的格式格式如下:
{ "iss": "https://accounts.google.com" "aud": [project-id], "nbf": number, "iat": number, "exp": number, "jti": string }