Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
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

Closed

Description

@jpambrun
  • OS: Linux
  • Node.js version: v12.19.0
  • npm version: 6.14.8
  • @google-cloud/storage version: 5.7.0

Steps to reproduce

  1. 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.
  2. Run
const {Storage} = require('@google-cloud/storage');
storage = new Storage({
        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] = await storage.bucket('vision-poc').getFiles();
        console.log(files) // works, I can see the .keep file.
        await storage.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.

It looks like #1316 was meant to fix it?

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jan 7, 2021
  2. ashokkumarsand commented on Feb 27, 2021

    @ashokkumarsand

    I am also facing the same issue.

  3. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Mar 31, 2021
  4. shaffeeullah commented on Mar 31, 2021

    @shaffeeullah
    Contributor

    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.

  5. self-assigned this
    on May 3, 2021
  6. KieranHarper commented on May 29, 2022

    @KieranHarper

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/nodejs-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions