I am getting the following error when I try to open a websocket.
Invalid access to resource - /speech-to-text/api/v1/recognize?model=en-US_BroadbandModel&watson-token=
User access not Authorized.
Gateway Error Code : ERCD04-NOAUTHHDR-PLTFRMREQ
Unable to communicate with Watson.
Request URL : /speech-to-text/api/v1/recognize?model=en-US_BroadbandModel&watson-token=
Error Id : stream-dp01-47767984
Date-Time : 2016-03-26T16:05:04-04:00
I have no idea what this error means. I am using this client code in Golang to open the websocket.
// Simplified code to get token
baseURL, _ := url.Parse("https://stream.watsonplatform.net/authorization/api/v1/token")
params := url.Values{}
params.Add("url", "https://stream.watsonplatform.net/speech-to-text/api")
baseURL.RawQuery = params.Encode()
req, _ := http.NewRequest(http.MethodGet, baseURL.String(), nil)
req.SetBasicAuth(IBMUsername, IBMPassword)
resp, _ := http.DefaultClient.Do(req)
token, _ := ioutil.ReadAll(resp.Body)
// Simplified code to open websocket
baseURL, _ := url.Parse("wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize")
params := url.Values{}
params.Add("watson-token", token)
params.Add("model", "en-US_BroadbandModel")
baseURL.RawQuery = params.Encode()
ws, _ := websocket.Dial(baseURL.String(), "", "http://localhost:8000")