google-cloud-node icon indicating copy to clipboard operation
google-cloud-node copied to clipboard

Unable to authenticate using `client_email` and `private_key` credentials object

Open Kylar13 opened this issue 3 years ago • 1 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Environment details

  • OS: Mac OS 12.6
  • Node.js version: v16.18.1
  • npm version: 8.19.2
  • @google-cloud/documentai: 6.1.0
  • google-gax: 3.5.2

Steps to reproduce

import { DocumentProcessorServiceClient } from "@google-cloud/documentai/build/src/v1";
const client = new DocumentProcessorServiceClient({
    options: {
      credentials: {
        client_email: "***",
        private_key: "***",
      },
      projectId: "***",
      apiEndpoint: "eu-documentai.googleapis.com",
    },
  });

Error:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
    at GoogleAuth.getApplicationDefaultAsync (node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:206:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async GoogleAuth.getClient (node_modules/google-gax/node_modules/google-auth-library/build/src/auth/googleauth.js:638:17)
    at async GrpcClient._getCredentials (node_modules/google-gax/src/grpc.ts:207:20)
    at async GrpcClient.createStub (node_modules/google-gax/src/grpc.ts:409:19)

Kylar13 avatar Dec 29 '22 14:12 Kylar13

Hi @Kylar13, I'll dig into this more if you're still having issues, but it seems that at a cursory glance, you can just set your credentials as a top-level object, like:

const client = new DocumentProcessorServiceClient({
      credentials: {
        client_email: "***",
        private_key: "***",
      },
      projectId: "***",
      apiEndpoint: "eu-documentai.googleapis.com",
    });

sofisl avatar Jan 05 '23 20:01 sofisl