-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access denied due to invalid subscription key or wrong API endpoint (Cognitive Services Custom Vision) #10362
Comments
@ramya-rao-a I have checked the provided steps and also my previous projects and created new projects and tested it. The service is returning the same error as "Access denied due to invalid subscription key or wrong API endpoint". I have validated the values with the portal. The URL/Endpoint, headers are all the same. When I try using the portal, it is suceeding. In our SDK it is failing. I have also validated with previous SDK releases. All of them report the same error. I think the service team must take a look at this issue since I do not find any issue with our side. |
The latest package version is 5.1.1, but all that included was a change in the readme file. The previous version 5.1.0 released 24 days ago had the changes from re-generating the package for the swagger update made in Azure/azure-rest-api-specs#9522. Can you please investigate? |
The issue is with the credentials class that is being used. CustomVision doesn't use import { TrainingAPIClient } from "@azure/cognitiveservices-customvision-training";
const { ApiKeyCredentials} = require("@azure/ms-rest-azure-js");
const credentials = new ApiKeyCredentials({ inHeader: { "Training-key": trainingKey } });
const client = new TrainingAPIClient(credentials, "https://eastus.api.cognitive.microsoft.com");
const projects = client.getProjects() For a more detailed sample take a look at our Quickstart For JavaScript |
@areddish thanks, I got my sample from the official @azure/cognitiveservices-customvision-training npm package documentation, we need to fix that: //. ..
const cognitiveServiceCredentials = new CognitiveServicesCredentials(customVisionTrainingKey);
const client = new TrainingAPIClient(cognitiveServiceCredentials, customVisionTrainingEndPoint);
// ... I tried running your code but I'm getting an error: It also printed my key in the console. Is it possible to implement in a way that this can't happen? |
@epomatti My apologies, I copied the imports from your example and didn't notice that my imports are using a different msRest package. import { ApiKeyCredentials } from "@azure/ms-rest-js"; |
@areddish I didn't see it as well 😁 It works. I forked it and sent this pull request to reflect that change in the documentation. Anything that can be done about the key being printed in the console when an exception occurs? |
Thanks @areddish! Has this always been the case or any recent change in the service? Thanks for the PR @epomatti! @sarangan12, Any questions you have for @areddish? |
@epomatti What exception caused the key to print into the console? The above screen shot is a code generation/transpile error that is dumping the line of code. That would be expected as it's a dev environment thing using node or tsc. @ramya-rao-a A few changes back (few months) we aligned with the cognitive services to use the credentials classes. But it's only been ApiKeyCredentials. It looks like the npm doc example has been wrong for years (several versions). |
@areddish you're right, I hardcoded it to make it short and that obviously will be printed (*facepalm). |
I'm trying to connect to my Cognitive Services resource but I'm getting the following error:
I created the the resource with kind
CognitiveServices
like this:Using kind
CustomVision.Training
didn't work too.I have already looked at this answer but it is no the same problem. I believe I am entering the correct credentials and endpoint.
I checked both Azure Portal and customvision.ai resource, I'm using the correct URL and key, but it is not working.
I even tried reseting the key but also it had no effect.
I was also able to run it using the REST API and also the C# SDK and it is working.
The text was updated successfully, but these errors were encountered: