GCE - 基本 API 用法 - 实例
GCE - basic API usage - Instances
我想在 Python API 中使用 "Instances"...出于某种原因,我的代码 returns 出现空错误:
Error: []
我的代码:
email = "somecode@developer.gserviceaccount.com"
with open("somefile.p12") as f:
pkey = f.read()
cred = SignedJwtAssertionCredentials(email,key, "https://www.googleapis.com/auth/devstorage.read_write")
compute = build('compute','v1',credentials=cred)
然后使用最简单的 API 调用:
compute.instances().list(project="firebase-client", zone="us-central1-f").execute()
弹出错误...
正如评论中提到并确认的那样,这里的解决方案是使用正确的范围:https://www.googleapis.com/auth/compute
是您想要对 Google Compute Engine API 进行读写访问的范围s.
问题代码示例中的范围 URL:https://www.googleapis.com/auth/devstorage.read_write
改为提供对 Google 云存储 API 的读写访问权限。
我想在 Python API 中使用 "Instances"...出于某种原因,我的代码 returns 出现空错误:
Error: []
我的代码:
email = "somecode@developer.gserviceaccount.com"
with open("somefile.p12") as f:
pkey = f.read()
cred = SignedJwtAssertionCredentials(email,key, "https://www.googleapis.com/auth/devstorage.read_write")
compute = build('compute','v1',credentials=cred)
然后使用最简单的 API 调用:
compute.instances().list(project="firebase-client", zone="us-central1-f").execute()
弹出错误...
正如评论中提到并确认的那样,这里的解决方案是使用正确的范围:https://www.googleapis.com/auth/compute
是您想要对 Google Compute Engine API 进行读写访问的范围s.
问题代码示例中的范围 URL:https://www.googleapis.com/auth/devstorage.read_write
改为提供对 Google 云存储 API 的读写访问权限。