我们已在Google云端控制台上创建了云扳手实例和数据库。
我们正在执行的代码段。
def getDatabaseList(self,):
try:
parent = "projects/"+self._PROJECT_NAME + "/instances/" + self._INSTANCE_NAME
response = self.service.projects().instances().databases().list(parent=parent).execute()
except Exception, e:
logging.info("Exception while getDatabaseList %s", e)
return False
return response
在上面的代码片段中,self.service是对象googleapiclinet库构建对象。
我们在使用服务帐户ID执行上面的代码段时遇到异常。
Exception while getDatabaseList <HttpError 403 when requesting https://spanner.googleapis.com/v1/projects/<projectName>/instances/<instanceName>/databases?alt=json&key=<APIKEY>
returned "Resource projects/<projectName>/instances/<instanceName> is missing IAM permission: spanner.databases.list.">
答案 0 :(得分:0)
有点晚了,但希望这会有所帮助:您是否正确设置了服务帐户的json文件的路径?我浪费了半天玩权限,直到我发现我只是错过了一个env键。
set export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service_account/key.json