c# - 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?
解决方案
正如@Jon Skeet在评论中提到的那样,这个问题与Cloud IAM和Cloud Storage 角色有关。根据错误消息,您的服务帐户没有所需的权限,例如storage.objects.list
.
要解决此问题,您可以创建一个新的服务帐户,授予 和 的角色storage.admin
,storage.object.admin
创建一个新密钥并使用它。
推荐阅读
- ios - 是否可以在 Scenekit 渲染和普通 iOS 应用程序渲染之间来回切换?
- html - 同一行上的引导导航栏
- javascript - Textarea 不更新道具更新:使用 React
- ruby-on-rails - 如何将变量传递给哈希字段上的 mongoid 查询
- java - 在通知右侧添加图标按钮
- java - switch 语句的问题
- powershell - 如何交换多个文件名的一部分?
- python - 如何使用 pybuilder 设置 python 项目并表现
- function - Toggle Haskell 语言中的案例
- ms-access - 如何使用 ADODB 在 Access 表单中添加下一个和上一个