You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
"Could not load the default credentials" when using custom apiEndpoint. #1373
Start the GCP emulator docker image fsouza/fake-gcs-server with sh - c 'mkdir -p /data/bucketname && touch /data/bucketname/.keep && /bin/fake-gcs-server -scheme http -port 80 -data /data' as entrypoint.
Run
const{Storage}=require('@google-cloud/storage');storage=newStorage({apiEndpoint: 'http://google-cloud-storage.gcp-emu',// whatever IP/domain needed to reach the emulator of step 1.projectId: 'gcp-emu-prj',});(async()=>{const[files]=awaitstorage.bucket('vision-poc').getFiles();console.log(files)// works, I can see the .keep file.awaitstorage.bucket('vision-poc').file('my-file').save('test from js');})();
On the save() call I get:
(node:958) UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/root/node_modules/google-auth-library/build/src/auth/googleauth.js:157:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async GoogleAuth.getClient (/root/node_modules/google-auth-library/build/src/auth/googleauth.js:490:17)
at async GoogleAuth.request (/root/node_modules/google-auth-library/build/src/auth/googleauth.js:543:24)
at async Upload.makeRequest (/root/node_modules/gcs-resumable-upload/build/src/index.js:320:21)
at async Upload.createURIAsync (/root/node_modules/gcs-resumable-upload/build/src/index.js:145:22)
(node:958) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
I don't expect any attempt to load credentials since I am supplying a custom API endpoint.
Maybe related to fsouza/fake-gcs-server#218, #898, #1315.
This error is occurring because authentication bypass for resumable uploads is not currently supported. A potential workaround for this issue is to add {resumable: false} as the second parameter to your File.save call.
I have noticed this occurring in version 6.0.1 today when using getSignedUrl for an upload. It will only succeed in giving you a url if you have credentials. Other calls are respecting apiEndpoint. My quick workaround was to manually construct a fake url instead, because this is just for a test env using fsouza/fake-gcs-server as above.
Activity
ashokkumarsand commentedon Feb 27, 2021
I am also facing the same issue.
shaffeeullah commentedon Mar 31, 2021
This error is occurring because authentication bypass for resumable uploads is not currently supported. A potential workaround for this issue is to add
{resumable: false}as the second parameter to yourFile.savecall.KieranHarper commentedon May 29, 2022
I have noticed this occurring in version 6.0.1 today when using
getSignedUrlfor an upload. It will only succeed in giving you a url if you have credentials. Other calls are respectingapiEndpoint. My quick workaround was to manually construct a fake url instead, because this is just for a test env usingfsouza/fake-gcs-serveras above.