Giter VIP home page Giter VIP logo

Comments (3)

bcoe avatar bcoe commented on July 21, 2024

@pvhieuit I believe you should be able to pass in an auth instance like this:

const authClient = auth.fromJSON(keys)
const client = new CloudBuild({
  auth: authClient
})

☝️ does this approach work for you?

from nodejs-cloudbuild.

pvhieuit avatar pvhieuit commented on July 21, 2024

@bcoe thank you for help, but it not working.

image

from nodejs-cloudbuild.

dinagraves avatar dinagraves commented on July 21, 2024

Where are you running the code? Depending on the environment, you can use the default authorization of the caller. If you don't specify auth, it uses the default. For instance, this works for me when I'm running locally:

  // Imports the Google Cloud client library
  const {CloudBuildClient} = require('@google-cloud/cloudbuild');

  // Creates a client
  const cb = new CloudBuildClient();

  const request = {
    projectId
  }

  const result = await cb.listBuildTriggers(request)
  console.info(result)

If this doesn't work, you can try running gcloud auth application-default login (info here) and then try again.

If you want to explicitly pass credentials through, you can use a service account key like this:

/  // Imports the Google Cloud client library
const {CloudBuildClient} = require('@google-cloud/cloudbuild');

client_options = {"keyFilename": "cloudbuildkey.json"}

// Creates a client
const cb = new CloudBuildClient(client_options)

const request = {
  projectId
}

const result = await cb.listBuildTriggers(request)
console.info(result)

Make sure your service account has permission to use the Cloud Build API. I gave mine the Cloud Build Service Agent role.

You can see more about authentication options here.

from nodejs-cloudbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.