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 with getSignedUrl. #2197

Open

Description

@psigen

Environment details

  • OS: Ubuntu 22.04
  • Node.js version: v18.15.0
  • npm version: 9.5.0
  • @google-cloud/storage version: 6.10.0

Steps to reproduce

Run the following code when using a storage emulator such as fake-gcs-server or firebase storage emulator:

import { Storage } from "@google-cloud/storage";

const storage = new Storage({
  apiEndpoint: 'http://localhost:9199',
  projectId: 'random-fake-proj-id',
  useAuthWithCustomEndpoint: false,
});

const expiration = new Date();
const expirationSecs = 60 * 10; // 10 minutes
expiration.setSeconds(expirationSecs);

const options = {
  version: "v4" as const,
  action: "read" as const,
  expires: expiration,
};

const [url] = await storage.bucket(BUCKET_NAME)
  .file(path)
  .getSignedUrl(options);

This will return the following error about credentials, even though the emulator doesn't use credentials, so they aren't needed to sign the URL:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
    at GoogleAuth.getApplicationDefaultAsync (/app/api/index.js:65733:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async GoogleAuth.getClient (/app/api/index.js:66050:20)
    at async GoogleAuth.getCredentialsAsync (/app/api/index.js:66009:24)
    at async sign (/app/api/index.js:93784:33)

This was previously mentioned in a comment on this previous ticket: #1373 (comment)

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 May 13, 2023
  2. changed the title [-]"Could not load the default credentials" when using custom apiEndpoint with getSignedUrl.[/-] [+]"Could not load the default credentials" when using custom apiEndpoint with `getSignedUrl.`[/+] on May 13, 2023
  3. ddelgrosso1 commented on May 18, 2023

    @ddelgrosso1
    Contributor

    @danielbankhead I poked into this a bit and it appears that the problem comes in that there doesn't appear to be a way to tell the auth library to "faux" sign a request. Is there a clean way we can bypass this in storage when the user does not want to use authentication?

  4. danielbankhead commented on Jun 1, 2023

    @danielbankhead
    Contributor

    [discussed offline, sharing here] We may need to take a similar approach as googleapis/gcs-resumable-upload#416 for this issue.

  5. BrennaEpp commented on Nov 3, 2023

    @BrennaEpp

    Hijacking this issue to track the implementation of this feature:

    When a custom endpoint is set on the client, Sign URLs and Post Policies should automatically use that domain.

    Optional: allow users to set a custom hostname for Sign URL and Post policy methods

    See: go/signurl-custom-endpoint-gcs

  6. 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 Nov 14, 2023
  7. danielbankhead commented on Dec 13, 2023

    @danielbankhead
    Contributor
  8. removed their assignment
    on Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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