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 
相關問題