0
votes

I have been trying to run a query against IBM Watson Tone Analyzer service and keep getting an error that my service credentials are not recognized.

I am sure that I am entering the correct credentials. Here are the steps that I took to get the service credentials:

  1. Signed up with bluemix.net.
  2. Clicked on Tone Analyzer icon.
  3. Clicked on service credentials.
  4. Clicked on add credentials and used the credentials that were obtained from this step.

I followed these steps multiple times but keep running into same error: watson_developer_cloud.watson_developer_cloud_service.WatsonException: Unauthorized: Access is denied due to invalid credentials

I would really appreciate any insights here.

2
please remove the watson-dialog tag, this question is about tone analyzerLeo
also check if you're specifying the right service gatewayLeo
@Leo - I updated the tag in my edit of the post.William 'Bill' Wentworth

2 Answers

2
votes

I was just able to run a test without any errors. Here are the steps I took:

1. Created a new IBM Watson Tone Analyzer instance: toneanalyzer

2. Looked at the service credentials page: service (I've changed the username to "abcuser" and the password to "abcpass" for this example.)

3. I ran this curl command to test out my service:

    curl -u "{username}":"{password}" -H "Content-Type: application/json" -d "{\"text\": \"Hi Team, I know the times are difficult! Our sales have been disappointing for the past three quarters for our data analytics product suite. We have a competitive data analytics product suite in the industry. But we need to do our job selling it! \"}" "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2016-05-19"

so replacing the username and password, I get...

    curl -u "abcuser":"abcpass" -H "Content-Type: application/json" -d "{\"text\": \"Hi Team, I know the times are difficult! Our sales have been disappointing for the past three quarters for our data analytics product suite. We have a competitive data analytics product suite in the industry. But we need to do our job selling it! \"}" "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2016-05-19"

4. Finally, I got this response:

{
    "document_tone":{
        "tone_categories":[
            {
                "tones":[
                    {
                        "score":0.455891,
                        "tone_id":"anger",
                        "tone_name":"Anger"
                    },
                    {
                        "score":0.156707,
                        "tone_id":"disgust",
                        "tone_name":"Disgust"
                    },
                    {
                        "score":0.17315,
                        "tone_id":"fear",
                        "tone_name":"Fear"
                    },
                    {
                        "score":0.190073,
                        "tone_id":"joy",
                        "tone_nam e":"Joy"
                    },
                    {
                        "score":0.291627,
                        "tone_id":"sadness",
                        "tone_name":"Sadness"
                    }
                ],
                "category_id":"emotion_tone",
                "category_name":"Emotion Tone"
            },
            {
                "tones":[
                    {
                        "score":0.459,
                        "tone_id":"analytical",
                        "tone_name":"Analytical"
                    },
                    {
                        "score":0.0,
                        "tone_id":"confident",
                        "tone_name":"Confide nt"
                    },
                    {
                        "score":0.0,
                        "tone_id":"tentative",
                        "tone_name":"Tentative"
                    }
                ],
                "category_id":"language_tone",
                "category_name":"Language Tone"
            },
            {
                "tones":[
                    {
                        "score":0.03,
                        "tone_id":"openness_big5",
                        "tone_name":"Openness"
                    },
                    {
                        "score":0.188,
                        "tone_id":"conscientiousness_big5",
                        "tone_nam e":"Conscientiousness"
                    },
                    {
                        "score":0.405,
                        "tone_id":"extraversion_big5",
                        "tone_name":"Extraversion"
                    },
                    {
                        "score":0.879,
                        "tone_id":"agreeableness_big5",
                        "tone_name":"Agreeableness"
                    },
                    {
                        "score":0.962,
                        "tone_id":"emotional_range_big5",
                        "tone_name":"Emotional Range"
                    }
                ],
                "category_ id":"social_tone",
                "category_name":"Social Tone"
            }
        ]
    }
}

Edit:

If you are having trouble with the Python SDK, try this:

import json
from watson_developer_cloud import ToneAnalyzerV3Beta


tone_analyzer = ToneAnalyzerV3Beta(
    url='https://gateway.watsonplatform.net/tone-analyzer/api',
    username='USERNAME',
    password='PASSWORD',
    version='2016-02-11')

print(json.dumps(tone_analyzer.tone(text='I am very happy'), indent=2))
2
votes

From your post above it looks you are doing the right thing with credentials, but trying to use them against a Beta instance of Tone Analyzer service.

As some background to understand any comments below: Tone Analyzer became "GA" on May 20th. Previously, it was "Beta". The Beta plan has URL https://gateway.watsonplatform.net/tone-analyzer-beta/api, while GA uses .../tone-analyzer/api (no -beta). Additionally if you are doing Python, there are two wrappers: ToneAnalyzerV3Beta (Beta) and ToneAnalyzerV3 (GA). Since we are still transitioning, some people still use existing instances of Beta plans, and also wrappers for Beta still exist.

Most importantly, credentials for the Beta plan will not work in GA, and vice versa.

That said, you need to make sure you are consistently using the GA or "standard" plan everywhere:

  • In your app, bind a "Tone Analyzer" (not Beta) plan.
  • Make sure the API URL contains /tone-analyzer/api (no -beta)
  • In the wrapper (python, node, java, or your URL if you did your own), use the "GA" (anything without "Beta" suffix).

Another detail (which wrappers will handle for you transparently) is that ?version argument is 2016-05-19 for the last API version. You should be using this one to get the latest features...

Joe's answer is very detailed about the process, just make sure you distinguish this Beta vs GA thing. Please add another comment if you have more questions. I hope this helps!