Closed KerimG closed 6 years ago
Does your dashboard show anything like iam_description
? Your error is just that the parameter isn't called apikey
If you do not see anything related to iam_description
or iam
on your credentials:
apikey
you should be using api_key
If you are using IAM authentication and see things like iam
on your credentials page:
apikey
you should use iam_apikey
I'm having a similar issue. According to the current docs for this package, when using a vision service that was created recently, the service should be created with this template:
var visual_recognition = new VisualRecognitionV3({
url: config.VisionUrl,
version: config.VisionVersion,
iam_apikey: config.VisionKey
});
But when running this, the installed v3 code throws an exception because it wants api_key to be specified. The same code also don't like 'version' to be specified.
I've tried modifying the v3 code to work around the problem, but have not succeeded.
@anweshan
I do see iam_description but I don't have an iam_key. Using api_key returns a similar message, going "invalid api key"
@KerimG you need to set the iam_apikey
parameter in the constructor using the apikey
value from the credentials in the IBM Cloud console.
var visual_recognition = new VisualRecognitionV3({
iam_apikey: "{apikey}", // change here
version: "2018-03-19",
url: "https://gateway.watsonplatform.net/visual-recognition/api/"
});
I think you missed my last message.
I have no iam_apikey
in my credentials and neither api_key
nor apikey
work. I was out of the country and had no chance to continue on this issue, yet.
Imho this was closed prematurely, especially considering I don't seem to be the only one having this or similar to this issue.
@KerimG can you show me what you have in the credentials
object? I think you have an apikey
field. If you use that field as iam_apikey
it will work. See https://github.com/watson-developer-cloud/node-sdk#supplying-the-iam-api-key
Make sure you override the url
parameter also.
@KerimG We closed this issue because we were unable to duplicate the issue and it appears that it should be fixed if you correctly pass in your api key like we suggested above. I re-opened the issue because you asked, but will close if there is no more activity on this issue. Can you verify that the suggestion worked?
@anweshan thank you for re-opening.
Creating an instance as follows:
var visual_recognition = new VisualRecognitionV3({
iam_apikey: "{apikey}",
version: "2018-03-19",
url: "https://gateway.watsonplatform.net/visual-recognition/api/"
});
returns this error:
Error: {"context":{"requestId":"21722353","requestType":"incoming.Identity_Token","userAgent":"Go-http-client/1.1","clientIp":"176.95.130.239","url":"https://iam-id-2.eu-gb.bluemix.net","instanceId":"iamid-9fd57f7dc-rrv75","threadId":"7307d2","host":"iamid-9fd57f7dc-rrv75","startTime":"21.06.2018 07:43:11:796 UTC","endTime":"21.06.2018 07:43:11:861 UTC","elapsedTime":"65","locale":"en_US","clusterName":"iam-id-prlon04-6r67"},"errorCode":"BXNIM0415E","errorMessage":"Provided API key could not be found"}
I am pretty sure that that api key does exist. I will create another set of credential just to make sure. Does the role of the credential matter? When I try to create credentials with the role "writer" , I get a 400 error pop-up.
I created a new set of credentials and had the same issue.
I'm currently using the free plan for visual recognition, could it be that I reached my 1000 API calls limit? I don't feel like I did and the error message doesn't mention anything regarding that but is it possible? I'll create a new account just to test.
Looks like the API key isn't valid. Based on the error message: Provided API key could not be found
Here is a set of credentials that I just got after creating an instance:
{
"apikey": "N5msBe7aLCK05w2HSwbrr7iZyMftHMY9iC8-aMVVk804",
"iam_apikey_description": "Auto generated apikey during resource-key operation for Instance - crn:v1:staging:public:conversation:us-south:a/a2b41967b8284f612fd4b7fd00297819:49014c11-282a-4a74-87ab-8b3dc0777d9b::",
"iam_apikey_name": "auto-generated-apikey-933a2344-2baa-491c-8ed8-9a5ff1238ed3",
"iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager",
"iam_serviceid_crn": "crn:v1:staging:public:iam-identity::a/a2b41967b8284f612fd4b7fd00297819::serviceid:ServiceId-de9cbe30-b8ad-40df-b518-884fef8ec713",
"url": "https://gateway.watsonplatform.net/visual-recognition/api"
}
My API Key is:
N5msBe7aLCK05w2HSwbrr7iZyMftHMY9iC8-aMVVk804
To use the SDK I do:
var visual_recognition = new VisualRecognitionV3({
iam_apikey: "N5msBe7aLCK05w2HSwbrr7iZyMftHMY9iC8-aMVVk804",
version: "2018-03-19",
url: "https://gateway.watsonplatform.net/visual-recognition/api"
});
visual_recognition.classify({ }, (err, response) => {
console.log(err, response);
});
I think it's an account issue. I'm not sure why. I created a new account and things work there.
Thanks a lot for your help.
I created a visual recognition service and tested it with cURL like so:
curl -u "apikey:{apikey}" "https://gateway.watsonplatform.net/visual-recognition/api/v3/classify?url={image-url}&version=2018-03-19&classifier_ids=DefaultCustomModel_325422001"
and this works perfectly fine.When I try to do the same via:
I get the following error:
Expected behavior: Get response object containing classification.
Actual behavior: Receive unauthorized error.
Node version: 6.11.5
SDK version: 3.4.5dd
What I found out is that the cURL request above uses GET, while the SDK uses POST. I'm not sure whether that's causing the issue but I can't really find any difference.