首页 > 解决方案 > Google.GoogleApiException: 'Google.Apis.Requests.RequestError ... 没有 storage.objects.list 访问 Google

问题描述

我在https://gist.github.com/henrikj242/af06ac41fc9554dab387c0bb3a994f85尝试了此代码, 但在线foreach (var obj in storageClient.ListObjects(bucketName, ""))

Google.GoogleApiException: 'Google.Apis.Requests.RequestError ... 没有 storage.objects.list 访问 Google

这意味着我传入了无效的 bucketName?

标签: c#google-cloud-platform

解决方案


正如@Jon Skeet在评论中提到的那样,这个问题与Cloud IAMCloud Storage 角色有关。根据错误消息,您的服务帐户没有所需的权限,例如storage.objects.list.

要解决此问题,您可以创建一个新的服务帐户,授予 和 的角色storage.adminstorage.object.admin创建一个新密钥并使用它。

此外,请查看文档了解角色了解服务帐户


推荐阅读