Closed idodekerobo closed 4 months ago
it seems that you are checking if the GCE .env variable is there for auth and doesn't seem to support/work for passing in the parsed json directly.
Two things here:
new GoogleAuth({credentials})
or GoogleAuth#fromJSON
:import {GoogleAuth} from 'google-auth-library';
const auth = new GoogleAuth({credentials : {}});
Here are instructions for authenticating via Application Default Credentials:
okay it seems i'm authenticated. i'm able to see my storage buckets when loadCredentials runs above, but do you have any idea why am i still seeing errors when trying to call text to speech api? @danielbankhead
i've tried to use the api to output a speech file and to just output voices using googleTextToSpeechClient.listVoices({ languageCode })
. i've also double checked that my credentials are compatible with the Cloud Text-to-Speech API in the console of my project.
it also says not to use service account key, but it is not clear on how the app will be authorized in a deployed environment w/o using the keys? but maybe this is user error, but it only works when i add my json directly to my .env file like this GOOGLE_APPLICATION_CREDENTIALS=./firebase-service-account-key.json
i'm getting this error on both -
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/Users/idodekerobo/Documents/gCloudApp/node_modules/@google-cloud/text-to-speech/node_modules/google-auth-library/build/src/auth/googleauth.js:207:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async GoogleAuth.getClient (/Users/idodekerobo/Documents/gCloudApp/node_modules/@google-cloud/text-to-speech/node_modules/google-auth-library/build/src/auth/googleauth.js:624:17)
at async GrpcClient._getCredentials (/Users/idodekerobo/Documents/gCloudApp/node_modules/@google-cloud/text-to-speech/node_modules/google-gax/build/src/grpc.js:145:24)
at async GrpcClient.createStub (/Users/idodekerobo/Documents/gCloudApp/node_modules/@google-cloud/text-to-speech/node_modules/google-gax/build/src/grpc.js:308:23)
(node:95143) MetadataLookupWarning: received unexpected error = Invalid response from metadata service: incorrect Metadata-Flavor header. code = UNKNOWN
(Use `node --trace-warnings ...` to show where the warning was created)
There could be a compatibility issue with the file or it may not be found. Could you try passing the GoogleAuth
instance to the Text-to-Speech client?
when i instantiate gCloudStorage and call the loadCredentials function - i'm seeing data. but when i call it in my app (aka using text speech or something else. it says "Error: Could not load the default credentials"
i did some digging, and even tho when i
console.log(gCloudStorage.authClient)
it still showscheckIsGCE: undefined
. from digigng around in the package code, it seems that you are checking if the GCE .env variable is there for auth and doesn't seem to support/work for passing in the parsed json directly.this is necessary for hosting in a cloud environment where i'd need to add the json as an .env and can't directly put in file path to json. also seems related to this bug, but not sure if it is exactly the same.
would appreciate any help or feedback! i currently can't use my cloud storage or any of the google cloud compute my app is built on in production.
code snippet
Environment details