IBM Language Translator在identify()上返回403禁止访问

问题描述 投票:0回答:1

我按照官方文档创建了这里概述的多语言Watson助手:https://github.com/with-watson/multilingual-chatbot

但是,在将功能部署到IBM Cloud并通过IBM Cloud CLI使用以下命令测试了已部署的功能后,出现错误(以下日志):

bx wsk动作调用翻译器--result --param文本“ Hallo,ich habe eine Frage。”

{“错误”:“该操作未返回字典。”}

"2020-01-13T12:54:57.787506Z    stderr: Traceback (most recent call last):",
"2020-01-13T12:54:57.787554Z    stderr: File \"pythonrunner.py\", line 88, in run",
"2020-01-13T12:54:57.787560Z    stderr: exec('fun = %s(param)' % self.mainFn, self.global_context)",
"2020-01-13T12:54:57.787564Z    stderr: File \"<string>\", line 1, in <module>",
"2020-01-13T12:54:57.787568Z    stderr: File \"__main__.py\", line 98, in main",
"2020-01-13T12:54:57.787571Z    stderr: response = translator.identify( text )",
"2020-01-13T12:54:57.787575Z    stderr: File \"/action/virtualenv/lib/python3.6/site-packages/watson_developer_cloud/language_translator_v3.py\", line 193, in identify",
"2020-01-13T12:54:57.787579Z    stderr: accept_json=True)",
"2020-01-13T12:54:57.787583Z    stderr: File \"/action/virtualenv/lib/python3.6/site-packages/watson_developer_cloud/watson_service.py\", line 587, in request",
"2020-01-13T12:54:57.787587Z    stderr: info=error_info, httpResponse=response)",
"2020-01-13T12:54:57.787591Z    stderr: watson_developer_cloud.watson_service.WatsonApiException: Error: Forbidden, Code: 403",
"2020-01-13T12:54:57.788Z       stderr: The action did not initialize or run as expected. Log data might be missing."

看起来像可以识别API密钥,但不允许将其用于此操作,但是,通过cURL使用时,所使用的密钥确实返回正确的值。

main中执行的代码与上面Github上提供的代码相同,我没有做任何更改。

关于如何解决此问题的任何想法?谢谢!

ibm-cloud ibm-watson watson-assistant
1个回答
0
投票
curl使用的密钥字符串是不记名令牌。云功能所需的API密钥可能是IAM身份和访问管理提供的密钥。

在顶部的https://cloud.ibm.com控制台GUI中,单击管理>访问(IAM),然后选择左侧的IBM Cloud API密钥并选择一个API密钥。这将创建一个代表您的API密钥,就像登录名和凭据一样。这是使它工作的最简单方法,但不适用于生产。

对于生产,请考虑使用服务ID,并且可能与访问组结合使用。

© www.soinside.com 2019 - 2024. All rights reserved.