如何从 Google Smart Home Action 获取访问令牌?

How to get Access token from Google Smart Home Action?

我正在使用 Google 智能家居操作,我的技能已成功关联。获取以下 SYNC 意图。

{
    "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
    "inputs": [{
      "intent": "action.devices.SYNC"
    }]
}

但没有获得调用云的授权令牌api(当我们进入 Alexa 时),那么我怎样才能获得授权令牌?

Google 在调用您的 fulfillment URL 时在 Authorization header 上附加用户的访问令牌,如以下文档 Fulfillment and authentication:

When you have authenticated a user, the user's third-party OAuth 2 access token is sent in the Authorization header when smart home intents are sent to your fulfillment.

我能够通过检查 API 网关日志来解决它,我在 api 网关上收到访问令牌,但 api 网关只发送 body函数的一部分不是 header。

所以您需要做的只是在请求中手动添加 header(针对您的功能),然后您一定会收到该访问令牌。