【发布时间】:2012-03-02 13:14:38
【问题描述】:
我按照手册设置了谷歌云存储所需的环境。 我已经安装了“gsutil”并设置了所有路径。 我的 gsutil 运行良好,但是,当我尝试运行下面的代码时,
#!/usr/bin/python
import StringIO
import os
import shutil
import tempfile
import time
from oauth2_plugin import oauth2_plugin
import boto
# URI scheme for Google Cloud Storage.
GOOGLE_STORAGE = 'gs'
# URI scheme for accessing local files.
LOCAL_FILE = 'file'
uri=boto.storage_uri('sangin2', GOOGLE_STORAGE)
try:
uri.create_bucket()
print "done!"
except boto.exception.StorageCreateError, e:
print "failed"
它给出“403 Access denied”错误。
Traceback (most recent call last):
File "/Volumes/WingIDE-101-4.0.0/WingIDE.app/Contents/MacOS/src/debug/tserver/_sandbox.py", line 23, in <module>
File "/Users/lsangin/gsutil/boto/boto/storage_uri.py", line 349, in create_bucket
return conn.create_bucket(self.bucket_name, headers, location, policy)
File "/Users/lsangin/gsutil/boto/boto/gs/connection.py", line 91, in create_bucket
response.status, response.reason, body)
boto.exception.GSResponseError: GSResponseError: 403 Forbidden
<?xml version='1.0' encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access denied.</Message></Error>
因为我是新手,所以我很难弄清楚为什么。 有人能帮我吗? 谢谢。
【问题讨论】:
-
您是否在 Google API 控制台中激活了 Google 存储?您在哪里设置了需要针对 Google 服务进行身份验证的 oauth client_id、client_secret 等?
-
是的。我想我是在安装 gsutil 时这样做的,它工作正常。但是,上面的代码给了我“403 禁止”错误。我按照指示设置了 python 路径(export PYTHONPATH=${PYTHONPATH}:$HOME/gsutil/boto:$HOME/gsutil),但它仍然给我带来了问题。
标签: python google-app-engine google-cloud-storage