python – gcloud.exceptions.Forbidden:403权限丢失或不足
发布时间:2020-12-16 23:32:12 所属栏目:Python 来源:网络整理
导读:我是Google云端平台的新手.我已经设置了Google VM实例.运行命令时,我在Local Machine上遇到身份验证问题: python manage.py makemigrations 你能否提出一些建议/步骤来解决这个问题? 错误跟踪 File "/constants.py",line 18,in module table_data = datast
|
我是Google云端平台的新手.我已经设置了Google VM实例.运行命令时,我在Local Machine上遇到身份验证问题:
python manage.py makemigrations 你能否提出一些建议/步骤来解决这个问题? 错误跟踪 File "/constants.py",line 18,in <module>
table_data = datastore_fetch(project_id,entity_kind)
File "/datastore_helper.py",line 23,in datastore_fetch
results = list(query.fetch())
File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/query.py",line 463,in __iter__
self.next_page()
File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/query.py",line 434,in next_page
transaction_id=transaction and transaction.id,File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py",line 286,in run_query
_datastore_pb2.RunQueryResponse)
File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py",line 124,in _rpc
data=request_pb.SerializeToString())
File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py",line 98,in _request
raise make_exception(headers,error_status.message,use_json=False)
gcloud.exceptions.Forbidden: 403 Missing or insufficient permissions.
其他信息: gcloud auth list
Credentialed Accounts:
- user_account@gmail.com ACTIVE
To set the active account,run:
$gcloud config set account `ACCOUNT`
gcloud config list
Your active configuration is: [default]
[core]
account = user_account@gmail.com
disable_usage_reporting = True
project = user_project
输入:(独立Python函数) from gcloud import datastore
client = datastore.Client('user_project')
print(vars(client.connection.credentials))
输出: {'scopes': set([]),'revoke_uri': 'https://accounts.google.com/o/oauth2/revoke','access_token': None,'token_uri': 'https://www.googleapis.com/oauth2/v4/token','token_info_uri': None,'token_response': None,'invalid': False,'refresh_token': u'1/t-V_pZicXXXXXXXXXXXXXXXXXXXXXXXXXXXXX','client_id': u'3XXXXXXXX9.apps.googleusercontent.com','id_token': None,'client_secret': u'ZXXXXXXXXXXXXXXXXXXX2','token_expiry': None,'store': None,'user_agent': 'Python client library'}
VM细节 Firewalls Allow HTTP traffic Allow HTTPS traffic Availability policies Preemptibility Off (recommended) Automatic restart On (recommended) On host maintenance Migrate VM instance (recommended) Custom metadata None SSH Keys Block project-wide SSH keys None Service account service-account@user_project.iam.gserviceaccount.com Cloud API access scopes This instance has full API access to all Google Cloud services. 谢谢, 解决方法
自版本128以来,应用程序默认凭据的行为在gcloud中为
changed.
一个人应该使用 gcloud auth application-default login 代替. 请注意,通过gcloud auth login或gcloud init或gcloud配置帐户MY_ACCOUNT更改凭据不会影响应用程序默认凭据,它们与gcloud凭据分开管理. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
