简体   繁体   中英

Could not load the default credentials even after setting env

I set up env varible VISION_KEYFILE_JSON with key values of the vision app, when I console

console.log(`key: ${process.env.VISION_KEYFILE_JSON}`);

It gives the key, when executing the code

const client = new vision.ImageAnnotatorClient({ projectId: config.google.project_id});

I got the following error

Error: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.

How to solve this?

You need to also set GOOGLE_APPLICATION_CREDENTIALS for Application Default Credentials to work. I think setting it to the same value as VISION_KEYFILE_JSON is correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM