Configure vision client with API key?
See original GitHub issueEnvironment details
- OS: Mac OS
- Node.js version: 8.11.1
- npm version: 5.6.0
@google-cloud/vision
version: 0.19.0
Steps to reproduce
None, this is a question.
Question
Is it possible to configure the vision client with an API key rather than a Credentials object?
Our use case does not allow us checking in a credentials.json file into the repository, but we are able to use environment variables. It would be nice to be able to use the vision lib rather than POST
ing directly to the images:annotate
endpoint.
I’ve tried stringifying the Credentials object, then parsing and passing it into the constructor, but then I get strange errors like Auth error:Error: invalid_grant: Invalid JWT Signature.
Plus that just seems like more hoops to jump through than necessary, considering the Vision API supports API keys.
// Throws like 10 invalid_grant errors
const visionClient = new vision.ImageAnnotatorClient({
credentials: JSON.parse(GOOGLE_APPLICATION_CREDENTIALS),
});
visionClient.cropHints(buffer)
.then(results => console.log(results));
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Quickstart: Set up the Vision API - Google Cloud
In the Google Cloud console, click the email address for the service account that you created. · Click Keys. · Click Add key,...
Read more >How to Get Google Cloud Vision API Key | Daminion
To start working with Auto-tagging in Daminion, you first need to configure Google Cloud Vision API Key. To do this, log into your...
Read more >Using Google Vision API - Medium
First, create an API key accessing the GCP, going to MENU > APIs & Services > Credentials and clicking on Create credentials >...
Read more >Using the Vision API with Python - Google Codelabs
How to use Cloud Shell; How to Enable the Google Cloud Vision API; How to Authenticate API requests; How to install the Vision...
Read more >Using the Google Cloud Vision API with a simple API key
args) throws Exception { // Instantiates a client ImageAnnotatorClient vision = ImageAnnotatorClient.create(); ... BatchAnnotateImagesResponse ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@chougron Oh, this issue seems to be forgotten here, sorry for that! Using an API key from the Node.js application is a little bit tricky but totally possible. This gist shows the complete example, here is the main part of it:
Anyway, please be advised that we recommend using service account key for authentication on the server side, and OAuth2 for the client side authentication. Please consider using either of those instead of API key authentication.
Let me know if it helps!
@alexander-fenster your solution works without any issue .