googleapis/nodejs-vision

Getting empty response when using the API in Firebase Cloud Functions

SametSahin10 opened this issue · 1 comments

I'm using the Cloud Vision API in Firebase Cloud Functions. I can successfully send a request to Cloud Vision API and see the results while working in my local environment. When I deploy the code, the annotateImage function does not work properly. It returns a safeSearchAnnotation that is null and labelAnnotations that is empty. To test the API locally, I've generated a service account and a key with that service account. Then I exported the path to the key with:

export GOOGLE_APPLICATION_CREDENTIALS=${pathToTheKey}

This lets me use the API locally but I haven't done anything else to be able to use the API on production since it's stated that enabling the API in Google Cloud Console suffices. The API is already enabled. What could be the problem here?

Environment details

  • OS: The API call is made in Cloud Functions. So the OS is whatever Google chooses to run the Cloud Functions on.
  • Node.js version: The node version specified in package.json is 14.
  • npm version: I don't have access to the npm version since the API call is made on a Cloud Function.
  • @google-cloud/vision version: ^2.4.2

Steps to reproduce

  1. Try to annotate an image and check the SafeSearch Annotation and Label Annotations results.
  2. See that the safeSearchAnnotation is null and labelAnnotations is empty.

I just logged the error in annotate image response and saw this. I think I know what the issue is.

{"details":[],"code":4,"message":"We can not access the URL currently. Please download the content and pass it in."}