Closed kyokonishito closed 4 years ago
You need to pass it to the constructor:
var visualRecognition = new VisualRecognitionV3({
version: '2018-05-01',
apikey: 'YOU_IAM_API_KEY_VARIABLE'
});
My issue is the sdk does not read the api key from the credentials.env provided by the service explained as README.md, not how to pass the APIKEY.
This is a known issue and we are working on the fix.
The SDK will recognize VISUAL_RECOGNITION_
which is the one that in the credentials file.
In the meantime can you use the snippet from @msalimbe1?
const visualRecognition = new VisualRecognitionV3({
version: '2018-05-01',
apikey: process.env.VISUAL_RECOGNITION_IAM_APIKEY
});
@germanattanasio Thank you! I will pass the api key as your code until getting the fix.
The same issue is there with Watson Assistant. Not reading from ibm-credential.env file. If IAM credential is given in a ibm-credential.env file, AsistantV2 can not read it from that ".env" Always throwing Error: Missing required parameters: apikey. It only works if the credentials are passed in constructor directly. Used a work around: Using a json file say "watson-config.json" to store credential, then reading it using a small node module "read-search-json". (its my own contribution https://www.npmjs.com/package/read-search-json) A node module to read and search out JSON data from an input JSON file('*.json'). Inputs are the JSON file path and a Search Path constructed as a string array of Keys. Sample "watson-config.json" :
{
"watson-assistant-config": {
"apikey": "the-api-key",
"url": "the-url"
}
}
Sample Call : (assuming the "watson-config.json" in in the same folder from where "node" is running
const AssistantV2 = require('ibm-watson/assistant/v2');
const readjson = require('read-search-json');
readjson.readJSON("./watson-config.json", ["watson-assistant-config"], function (data, err) {
if (data) {
console.log(data);
var assistant = new AssistantV2(data);
// start Watson Assistant Session
}
if (err)
console.log(err);
});
This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@tanushreepaul04 Can you please show us the keys in the ibm-credentials.env
file? I think it's related to the keys not being the ones that the SDK is looking for
This issue has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Overview Visual Recognition doesn't recognize IAM_APIKEY and URL from credentials.env provided by the service. When I put the credentials.env provided by the visual recognition service to the working directory, the api returns 'Error: Missing required parameters: apikey'.
Expected behavior The apikey is loaded from credentials.env.
Actual behavior the api returns 'Error: Missing required parameters: apikey'.
How to reproduce
Screenshots If applicable, add screenshots to help explain your problem.
SDK Version v5.2.0
Additional information: The SDK only reads the variables started from WATSON_VISIONCOMBINED. However the values of credentials.env are started from VISUALRECOGNITION. SDK v4 reads both values.