【问题标题】:Using the Actions REST API Outside of Google Assistant?在 Google Assistant 之外使用 Actions REST API?
【发布时间】:2021-12-15 19:18:42
【问题描述】:

我们目前有一个谷歌操作,要求用户登录我们的系统,并且我们的 OAuth 帐户链接流程成功地提供了一个访问令牌,用于通过我们的履行后端进行身份验证。这在我们的 Action 在 Google Assistant 中进行查询时非常有用。

我们也有兴趣在我们的网络应用、iOS 应用和其他应用平台中将 Google Actions REST API 与自己的自定义聊天机器人结合使用,但在外部发出 Google Actions API 请求时的 Google 助理,我们不断收到 401 身份验证错误响应。

是否可以在 Google 助理环境之外使用 Google Actions REST API?如果是这样,那么有人可以告诉我们在 REST API 调用中缺少什么吗?

例如,根据 Google Actions REST API 文档 - https://developers.google.com/assistant/actions/api - 如果我们在通过命令行进行测试 Google Actions REST API 调用时通过“Authorization: Bearer”标头包含我们的有效 OAuth 访问令牌:

curl -X POST "https://actions.googleapis.com/v2/projects/[OUR PROJECT ID]:matchIntents" -H "Authorization: Bearer [OUR OAUTH ACCESS TOKEN]" -H "x-goog-user-project: [OUR PROJECT ID]" -H "User-Agent: [OUR APP PLATFORM/VERSION INFO]" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"query\": \"how much money do we owe\", \"locale\": \"en-US\"}"

无论我们如何调整标头,我们总是会收到 401 错误响应:

{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

我们已经在网上广泛搜索了任何故障排除提示,但没有找到任何关于我们可能在此处做错的问题的答案。我们的 API 调用中是否缺少某些内容-或- Google Actions REST API 是否根本无法在 Google Assistant 环境外部访问?任何帮助将不胜感激。

【问题讨论】:

    标签: rest actions-on-google


    【解决方案1】:

    Actions on Google/Actions Builder 平台不适合在 Google 助理环境之外使用。如果您想以编程方式匹配意图或调用 API,则应使用 Dialogflow 及其 API。

    【讨论】:

    • 感谢尼克的确认!非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多