验证请求 (Dialogflow)

使用授权令牌对对话 webhook 的请求进行签名 ,并采用以下格式:

authorization: "<JWT token>"

身份验证令牌遵循 JSON Web 令牌格式,其中“audience”字段值等于应用的 Actions 控制台项目 ID。如需验证签名,请解压缩令牌并确保“audience”字段与应用的项目 ID 相匹配。为此,您可以使用与 JWT 兼容的凭据库(例如 Google API Node.js 客户端),也可以直接使用 Actions on Google Node.js 客户端库 ActionsSdkOptions#verification 选项。

const {actionssdk} = require('actions-on-google');

const app = actionssdk({verification: 'nodejs-cloud-test-project-1234'});
// HTTP Code 403 will be thrown by default on verification error per request.