Cloud的访问范围Shell
The access scope of Cloud Shell
我尝试 运行 一个 docker 容器应用程序,它访问云中的 Cloud Datastore Shell,但访问被拒绝。我怀疑 Cloud Shell 没有访问 Cloud Datastore 的范围。
是否可以为 Cloud Shell 实例添加适当的范围?
Cloud Shell 凭证处理中存在一个错误,使用更新版本的 Python oauth2client 包(直接或间接)会失败并出现类似
的错误
File "/usr/local/lib/python2.7/dist-packages/oauth2client/contrib/gce.py", line 117, in _retrieve_info
self.service_account_email = info['email']
TypeError: string indices must be integers
这应该会在较新的映像版本中得到修复。 Cloud Shell 的新会话应该不会出现此问题。这是在容器中使用 Cloud Datastore API,在 Cloud Shell:
中使用 运行 的工作示例
$ cat Dockerfile
FROM python
RUN pip install gcloud
COPY test.py .
CMD ["python", "test.py"]
$ cat test.py
from gcloud import datastore
client = datastore.Client(project='your-project-id-23242')
query = datastore.Query(client, kind='EntityKind')
print(list(query.fetch()))
$ docker build -t test .
... docker output ...
$ docker run -ti test
[]
该示例仅打印出一个空列表,因为我的项目数据存储区中没有 "EntityKind" 类型的任何实体,但您明白了。
P.S。我在 Google.
工作
我尝试 运行 一个 docker 容器应用程序,它访问云中的 Cloud Datastore Shell,但访问被拒绝。我怀疑 Cloud Shell 没有访问 Cloud Datastore 的范围。
是否可以为 Cloud Shell 实例添加适当的范围?
Cloud Shell 凭证处理中存在一个错误,使用更新版本的 Python oauth2client 包(直接或间接)会失败并出现类似
的错误File "/usr/local/lib/python2.7/dist-packages/oauth2client/contrib/gce.py", line 117, in _retrieve_info
self.service_account_email = info['email']
TypeError: string indices must be integers
这应该会在较新的映像版本中得到修复。 Cloud Shell 的新会话应该不会出现此问题。这是在容器中使用 Cloud Datastore API,在 Cloud Shell:
中使用 运行 的工作示例$ cat Dockerfile
FROM python
RUN pip install gcloud
COPY test.py .
CMD ["python", "test.py"]
$ cat test.py
from gcloud import datastore
client = datastore.Client(project='your-project-id-23242')
query = datastore.Query(client, kind='EntityKind')
print(list(query.fetch()))
$ docker build -t test .
... docker output ...
$ docker run -ti test
[]
该示例仅打印出一个空列表,因为我的项目数据存储区中没有 "EntityKind" 类型的任何实体,但您明白了。
P.S。我在 Google.
工作