Watson Discovery“由于凭据无效而拒绝访问” - Python

时间:2017-09-14 20:12:54

标签: python python-3.x ibm-watson watson-discovery

我想使用IBM Watson Discovery Services,但在尝试时收到错误消息。 错误消息为:WatsonException: Unauthorized: Access is denied due to invalid credentials

import sys  
import os  
import json  
from watson_developer_cloud import DiscoveryV1  

discovery = DiscoveryV1(  
    username="{bbbaaaaa}",  
    password="{aaaaaabbbb}",  
    version="2017-09-01"
)  

qopts = {'query': 'enriched_text.entities.text:IBM'}  
my_query = discovery.query('system', 'news', qopts)  
print(json.dumps(my_query, indent=2))

1 个答案:

答案 0 :(得分:2)

从您的用户名和密码中删除{}

现在应该是

discovery = DiscoveryV1(  
    username="aaaaabbbbbb",  
    password="bbbbbaaaaa",  
    version="2017-09-01"
)