Watson Discovery "Access is denied due to invalid credentials" - Python

700 views Asked by At

I want to use IBM Watson Discovery Services but I am receiving an error message when trying to. The error message is: 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

There are 1 answers

1
James On BEST ANSWER

Remove the { and the } from your username and password.

It should now be

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