从ASP.NET在本地访问Google Cloud Datastore会引发Grpc.Core.RpcException:“缺少权限或权限不足". [英] Accessing Google Cloud Datastore locally from ASP.NET throws Grpc.Core.RpcException: "Missing or insufficient permissions."

查看:91
本文介绍了从ASP.NET在本地访问Google Cloud Datastore会引发Grpc.Core.RpcException:“缺少权限或权限不足".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注将Cloud Datastore与.NET结合使用教程.在某些时候,它表示您只需按F5即可在本地运行提供的项目.当我这样做时,我得到以下异常

I'm following the Using Cloud Datastore with .NET tutorial. At some point it says that you can run the provided project locally by just pressing F5. When I do that I get the following exception

Grpc.Core.RpcException:'状态(StatusCode = PermissionDenied,Detail =缺少或权限不足.")'

Grpc.Core.RpcException: 'Status(StatusCode=PermissionDenied, Detail="Missing or insufficient permissions.")'

此异常恰好抛出在_db.RunQuery(query)行上.

This exception is thrown exactly at the _db.RunQuery(query) line.

var query = new Query("Book") { Limit = pageSize };
if (!string.IsNullOrWhiteSpace(nextPageToken))
    query.StartCursor = ByteString.FromBase64(nextPageToken);
var results = _db.RunQuery(query);`

如果我将应用程序部署到云中,它将按预期工作,没有错误.我已经向Cloud IAM(身份和访问管理)中的所有帐户授予了数据存储区所有者权限,但仍然无法使用.有人有什么主意吗?

If I deploy the application to cloud it works as expected, no error. I've given datastore owner permissions to all accounts in Cloud IAM (Identity and Access Management) but it still doesn't work. Does anybody have any ideas?

推荐答案

正如Jon Skeet指出的那样,我在本地使用了错误的json密钥.以前,我创建了一个具有单独服务帐户的计算引擎.从 Console-> IAM&管理员->服务帐户,它也可以在本地使用.

As Jon Skeet pointed out, I was using the wrong json key locally. Previously I created a compute engine that has a separate service account. After I downloaded a new json key from Console -> IAM & Admin -> Service Accounts it worked locally as well.

这篇关于从ASP.NET在本地访问Google Cloud Datastore会引发Grpc.Core.RpcException:“缺少权限或权限不足".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆