google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

List all projects without OAuth2

Open francesco-clementi opened this issue 7 years ago • 3 comments

Is it possible to use the resource manager to list all projects with a service account? How con I use the resource manager api with this package?

francesco-clementi avatar Dec 05 '19 15:12 francesco-clementi

@francesco-clementi-bip :wave: it should be possible to use a service account:

  1. create and download the service account credentials, as a JSON file.
  2. set the variable GOOGLE_APPLICATION_CREDENTIALS, which should be the absolute path to the JSON file created in step 1.

There is documentation on this topic here.

Let me know if this does the trick for you.

bcoe avatar Dec 06 '19 00:12 bcoe

Hi, thanks for your response. I managed to use a service account with permissions of owner and browser, but the resource manager api return only one project (the one of the service account), but I need all the projects. Any idea?

francesco-clementi avatar Dec 07 '19 09:12 francesco-clementi

Here the code that I'm trying and that return only the project with service account, even if I set the role of browser. const {Resource} = require('@google-cloud/resource'); const keyFilename = 'path_to_json_service_account'; const resource = new Resource({keyFilename}); const [projects] = await resource.getProjects(); console.log("PROJECTS",projects)

francesco-clementi avatar Dec 07 '19 10:12 francesco-clementi