【发布时间】:2015-09-06 15:33:16
【问题描述】:
我想在 Python API 中使用“实例”...由于某种原因,我的代码返回空错误:
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()
错误弹出...
【问题讨论】:
-
您使用
pkey = ...,但随后将其用作SignedJwtAssertionCredentials(email, key, ...)— 是拼写问题吗? -
另外,这是我在 Python 中实现 GCE 身份验证的方法:github.com/mbrukman/cloud-launcher/blob/master/src/… — 请注意,我在此处请求计算范围
https://www.googleapis.com/auth/compute。 -
是的,范围 url 确实是问题所在。 (pkey 在我的代码上没问题:))谢谢 :]