node.jsibm-watsonvisual-recognition

Watson Visual Recognition - Unauthorized


I am trying to use the Watson Visual Recognition service with the watson-developer-cloud NPM module. But I always get the following error. What am I doing wrong?

 Unauthorized: Access denied due to invalid credentials.

I already searched for hours and found many people with the same problem, but none of the answers resolved the issue.

My service authentication informations (just test data):

 {
   "apikey": "API_KEY",
   "iam_apikey_description": "...",
   "iam_apikey_name": "...",
   "iam_role_crn": "...",
   "iam_serviceid_crn": "...",
   "url": "https://gateway.watsonplatform.net/visual-recognition/api"
 }

My Node.js code to create the VisualRecognizionV3 object:

 let visualRecognition = new VisualRecognizionV3({
     api_key: "API_KEY",
     version: "2018-03-19"
 });

I will appreciate your help!


Solution

  • I believe you need to specify the api_key with the iam_apikey parameter name, like this: let visualRecognition = new VisualRecognizionV3({ iam_apikey: "API_KEY", version: "2018-03-19" });

    See the doc here