我创建了一个谷歌云项目并启用了谷歌云密钥管理服务 (KMS) API。我创建了两个钥匙圈。keyring1
位于us-east1
并且keyring2
位于global
。我创建了以下 java 程序来列出该区域中的密钥环:
GoogleCredential credential = GoogleCredential.getApplicationDefault();
credential = credential.createScoped(CloudKMSScopes.all());
String keyRingPath = "projects/<<projectId>>/locations/global";
CloudKMS kms = new CloudKMS.Builder(httpTransport, jsonFactory, credential).setApplicationName("CloudKMS snippets").build();
ListKeyRingsResponse response = kms.projects().locations().keyRings().list(keyRingPath).execute();
System.out.println(response.getKeyRings());
我收到以下禁止错误:
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "This API is not acessible from your region.",
"reason" : "forbidden"
} ],
"message" : "This API is not acessible from your region.",
"status" : "PERMISSION_DENIED"
}