0

我们在Google云端控制台上创建了云端扳手实例和数据库。使用服务帐号访问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."> 

参考文档cloud spanner IAM

回答

0

晚了一点,但希望这可以帮助:你有没有正确设置路径,您的服务帐户的JSON文件?我花了半天的时间玩这个权限,直到我发现我错过了一个env密钥。

set export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service_account/key.json 
相关问题