无法使用App Engine Admin API

时间:2018-04-19 11:46:49

标签: google-app-engine

我正在尝试以编程方式删除App Engine(标准)后端实例。删除它的代码在同一项目的另一个模块/服务上作为Servlet运行。

我能够列出实例和所有细节,但尝试删除它会引发403错误。

{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "message" : "Request had insufficient authentication scopes.",
    "reason" : "forbidden"
  } ],
  "message" : "Request had insufficient authentication scopes.",
  "status" : "PERMISSION_DENIED"
}

我正在使用App引擎默认服务帐户:

AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(AppengineScopes.APPENGINE_ADMIN));

Appengine engine = new Appengine.Builder(new UrlFetchTransport(), new JacksonFactory(), credential).setApplicationName("AppEngineManager").build();
//list all instances - this works fine

//now delete an instance
engine.apps().services().versions().instances().delete(appId, serviceId, version, <instanceid>).execute()

默认的App引擎服务帐户具有编辑角色(我也尝试手动添加App Engine管理员角色,但无济于事)

在运行代码之前打印的服务帐户名称也是正确的。可能有什么不对?

1 个答案:

答案 0 :(得分:1)

这解决了!

AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(AppengineScopes.**CLOUD_PLATFORM**));

我使用的是更加明显的AppengineScopes.APPENGINE_ADMIN,但这并不起作用。希望谷歌改进他们的文档。由于生产问题需要我们以编程方式删除实例以解决它而度过了一个不眠之夜。

相关问题