gpt4 book ai didi

python - 禁止 : 403 User not authorized even though the user is logged in

转载 作者:太空宇宙 更新时间:2023-11-03 15:58:07 24 4
gpt4 key购买 nike

我在 Mac 上尝试访问使用 Python 客户端的 URL 时收到 403 错误:

Traceback (most recent call last):
File "/Users/cchilders/.virtualenvs/myproject/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/cchilders/.virtualenvs/myproject/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/cchilders/work_projects/myproject/myproject/blueprints/admin.py", line 25, in health
return admin.Health.read()
File "/Users/cchilders/work_projects/myproject/myproject/views/admin.py", line 52, in read
if not topic.exists():
File "/Users/cchilders/.virtualenvs/myproject/lib/python2.7/site-packages/gcloud-0.18.3-py2.7.egg/gcloud/pubsub/topic.py", line 179, in exists
api.topic_get(topic_path=self.full_name)
File "/Users/cchilders/.virtualenvs/myproject/lib/python2.7/site-packages/gcloud-0.18.3-py2.7.egg/gcloud/pubsub/connection.py", line 171, in topic_get
return conn.api_request(method='GET', path='/%s' % (topic_path,))
File "/Users/cchilders/.virtualenvs/ourapi/lib/python2.7/site-packages/gcloud-0.18.3-py2.7.egg/gcloud/connection.py", line 347, in api_request
error_info=method + ' ' + url)
Forbidden: 403 User not authorized to perform this action. (GET https://pubsub.googleapis.com/v1/projects/myproject/topics/mytopic)
127.0.0.1 - - [10/Nov/2016 16:40:58] "GET /admin/health/ HTTP/1.1" 500 -

View /admin.py

    ps = pubsub.Client()
topic = ps.topic(application.config['PUBSUB_TOPIC'])
# topic.project = application.config['PUBSUB_PROJECT']
t_component = Component()
t_component.name = 'topic'
t_component.status = 'UP'
t_component.desc = ('{} exists and is healthy.'
.format(topic.full_name))
if not topic.exists():
t_component.status = 'DOWN'
t_component.desc = (
'Configured PUBSUB topic ({}) does not exist.'
.format(topic.full_name)
)

我创建了主题/订阅,因此我拥有权限。我的配置和 gcloud 用户是正确的,我进行了 gcloud auth ... 并仔细检查。我是唯一遇到此错误的人,并且我确实在这台笔记本电脑上使用了我的个人帐户来练习 gcloud 教程。我的同事认为过去使用其他帐户可能会导致问题。我检查了我的配置和我指向的项目,它是正确的项目。

最佳答案

gcloud auth logingcloud auth application-default login 之间存在差异

gcloud auth application-default login下重新登录已修复

关于python - 禁止 : 403 User not authorized even though the user is logged in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40591718/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com