3

I'm using node.js google api (npm gcloud package) to create a new project. this is a beta API. I'm getting an error: "The caller does not have permission" stack:

ApiError: The caller does not have permission at new util.ApiError (C:\app\bundle\a2\node_modules\gcloud\lib\common\util.js:92:10) at Object.parseHttpRespBody (C:\app\bundle\a2\node_modules\gcloud\lib\common\util.js:170:30) at Object.handleResp (C:\app\bundle\a2\node_modules\gcloud\lib\common\util.js:110:18) at C:\app\bundle\a2\node_modules\gcloud\lib\common\util.js:422:12 at Request.onResponse [as _callback] (C:\app\bundle\a2\node_modules\gcloud\node_modules\retry-request\index.js:117:7) at Request.init.self.callback (C:\app\bundle\a2\node_modules\gcloud\node_modules\request\request.js:199:22) at Request.emit (events.js:110:17) at Request. (C:\app\bundle\a2\node_modules\gcloud\node_modules\request\request.js:1036:10) at Request.emit (events.js:129:20) at IncomingMessage. (C:\app\bundle\a2\node_modules\gcloud\node_modules\request\request.js:963:12)

I already enabled "Google Cloud Resource Manager API". Other calls works OK. What may be the problem?

Galma88
  • 2,398
  • 6
  • 29
  • 50
Igal
  • 1,084
  • 2
  • 13
  • 33

2 Answers2

3

The Cloud Resource Manager's projects.create method is invite only per their documentation:

The projects.create() method is in the Alpha stage. It might be changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA or deprecation policy. Access to this feature is currently invite-only. For an invitation, contact our sales team.

Zack Butcher
  • 1,046
  • 7
  • 12
  • Thanks Zack, according to node.js documentation it's beta!? https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.27.0/resource?method=createProject I'm confused... – Igal Feb 10 '16 at 20:38
  • 3
    Every method of the Cloud Resource Manager API except `projects.create` is part of the beta, but `projects.create` is still in Alpha and requires an invite to use. The [gcloud docs](https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.27.0/resource?method=createProject) are for the gcloud client, but the [Cloud Platform docs](https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/create) are the authoritative docs for the API itself. – Zack Butcher Feb 10 '16 at 22:55
1

For that method, you must be authenticated as yourself, i.e. a service account JSON file won't work here. The only way to do that that I know of is by installing the gcloud SDK (https://cloud.google.com/sdk) and running gcloud auth login. When you instantiate gcloud, don't provide any credentials, only your project ID:

var gcloud = require('gcloud');
var resource = gcloud.resource({ projectId: 'grape-spaceship-123' });

// Now this should work:
resource.createProject('grape-spaceship-124', function(err, project) {});

Related material:

Stephen
  • 5,710
  • 1
  • 24
  • 32