简体   繁体   English

IBM Watson Machine Learning手写数字示例笔记本身份验证错误

[英]IBM Watson Machine Learning hand-written digits sample notebook authentication error

When working through section 6.1 of the Recognition of hand-written digits with IBM Watson Machine Learning notebook, calling the Watson Machine Learning REST API to get the list of published models using: 使用IBM Watson Machine Learning笔记本完成“ 识别手写数字”的 6.1节时,调用Watson Machine Learning REST API以使用以下方法获取已发布模型的列表:

GET /v3/wml_instances/{instance_id}/published_models

endpoint, there is a authorization (401) error with the following response text: 端点,出现授权(401)错误,并带有以下响应文本:

{"trace":"-1xmid60eblabs","errors":[{"code":"invalid_token_format","message":"Invalid token format. Bearer token format should be used.","target":{"type":"header","name":"Authorization"}}]}

The previous REST API call in the notebook to get the instance details using the authorization token returned from the /v3/identity/token endpoint worked ok. 笔记本中的上一个REST API调用使用从/v3/identity/token端点返回的授权令牌来获取实例详细信息,工作正常。

Looks like an error in the notebook. 看起来像笔记本中的错误。 Did the API authorization scheme change breaking the notebook? API授权方案是否改变了笔记本的规格?

This endpoint in the REST API appears to be expecting authentication of the form Authorization: <type> <credentials> per W3C in HTTP 1.0 REST API中的此终结点似乎期望采用以下形式的身份验证Authorization: <type> <credentials> HTTP 1.0中每个W3C的Authorization: <type> <credentials>

I updated the notebook code to add the type in the Authorization field of the header: 我更新了笔记本代码,以在标题的“授权”字段中添加类型:

header = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + mltoken}

The rest of the Watson Machine Learning API calls to create the online deployment and score new data use the same header in the notebook and all execute correctly. Watson Machine Learning API的其余调用用于创建在线部署并使用笔记本中的相同标头对新数据进行评分,并且所有标头均正确执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM