Reputation: 1080
I'm moving 3 Watson services from an old account to a Lite account (to avoid being charged on 1st December). The Text-to-Speech and Assistant services both work fine in the new account but I'm getting a 401 unauthorized error with the Speech-to-text (STT) service. All three are instantiated using the IAM apikey and associated urls, as indicated in my IBM console dashboard. If I switch STT back to my old account (username/password credentials) it works fine with the other two IAM services. The environment is a Java Spring-based website using the latest watson java-sdk (6.9.1) and latest speech-javascript-sdk. Here's the relevant entries from the log:
Nov 12, 2018 1:42:13 PM okhttp3.internal.platform.Platform log INFO: --> GET https://stream.watsonplatform.net/authorization/api/%2Fv1%2Ftoken?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi http/1.1
Nov 12, 2018 1:42:13 PM okhttp3.internal.platform.Platform log INFO: <-- HTTP FAILED: java.io.IOException: unexpected end of stream on Connection{stream.watsonplatform.net:443, proxy=DIRECT hostAddress=stream.watsonplatform.net/169.61.44.182:443 cipherSuite=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 protocol=http/1.1}
Nov 12, 2018 1:42:17 PM okhttp3.internal.platform.Platform log INFO: --> GET https://stream.watsonplatform.net/authorization/api/%2Fv1%2Ftoken?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi http/1.1
Nov 12, 2018 1:42:17 PM okhttp3.internal.platform.Platform log INFO: <-- 301 Moved Permanently https://stream.watsonplatform.net/authorization/api/%2Fv1%2Ftoken?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi (89ms, 129-byte body)
Nov 12, 2018 1:42:17 PM okhttp3.internal.platform.Platform log INFO: --> GET https://stream.watsonplatform.net/authorization/api/v1/token?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi http/1.1 Nov 12, 2018 1:42:17 PM okhttp3.internal.platform.Platform log
INFO: <-- 401 Unauthorized https://stream.watsonplatform.net/authorization/api/v1/token?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi (116ms, 103-byte body)
Nov 12, 2018 1:42:18 PM com.ibm.watson.developer_cloud.service.WatsonService processServiceCall SEVERE: GET https://stream.watsonplatform.net/authorization/api/v1/token?url=https%3A%2F%2Fstream.watsonplatform.net%2Fspeech-to-text%2Fapi, status: 401, error: Unauthorized
I've tried to determine what's causing the unexpected end of stream
(which is likely the true problem here) without success. For giggles, I tried adding a call to retrieve the SpeechModels list right after instantiating SpeechToText and it worked fine! Very curious. The "tip" that accompanies the last error above asks if the endpoint was set, and yes, it was set correctly.
Any help greatly appreciated.
Upvotes: 0
Views: 276
Reputation: 1080
Never mind. I was focused on the java error and didn't look that closely at the javascript side of the equation. I found this note in the node.js sdk:
NOTE: Authenticating with the X-Watson-Authorization-Token header or the watson-token query param is now deprecated. The token continues to work with Cloud Foundry services, but is not supported for services that use Identity and Access Management (IAM) authentication.
STT in my old account was a Cloud Foundry service which is why it continued to work. My bad for not doing more research...
Upvotes: 1