You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Smart Home Action对接Express API:令牌请求无参数问题求助

解决Google Smart Home令牌请求无参数的问题
  • Google的令牌交换请求是POST方式,而非GET,所以不能通过res.query获取参数,需从请求体中读取。
  • 检查Express中间件配置:必须添加解析请求体的中间件,否则无法读取参数:
    • 针对Google默认使用的x-www-form-urlencoded格式,添加:
      app.use(express.urlencoded({ extended: true }));
      
    • 若为JSON格式,添加:
      app.use(express.json());
      
  • 正确获取参数:在令牌交换端点中使用req.body提取所需字段,示例代码:
    app.post('/oauth/token', (req, res) => {
      const { client_id, client_secret, grant_type, code, redirect_uri } = req.body;
      // 执行令牌交换逻辑
      res.json({ access_token: 'your_generated_token', token_type: 'Bearer', expires_in: 3600 });
    });
    
  • 验证端点配置:确认Google Action控制台中令牌交换端点的请求方法为POST,且URL与Express路由完全一致,无拼写错误。

内容的提问来源于stack exchange,提问作者Kyaw Walar Htwe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 08:10:31