Credentials in boto

911 views
Skip to first unread message

Matt Hickford

unread,
Oct 23, 2011, 8:18:10 AM10/23/11
to gs-dis...@googlegroups.com
Hi. I'm trying to follow the boto Python library tutorial at http://code.google.com/apis/storage/docs/gspythonlibrary.html

When I run the Python code given in the tutorial, I get an exception at uri.create_bucket()

boto.exception.GSResponseError: GSResponseError: 403 Forbidden
<?xml version='1.0' encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access denied.</Message></Error>

Yes, nowhere in the code is a line to authenticate! How can the tutorial work? Has it been tested?

I followed the previous tutorial for the command-line utility gsutil at http://code.google.com/apis/storage/docs/hellogooglestorage.html . gsutil works correctly now, I ran 'gsutil config' as described at http://code.google.com/apis/storage/docs/gsutil_install.html which saved credentials in ~/.boto

Is the Boto python library meant to quietly look in ~/.boto when I import it? This is what gsutil does successfully. How can I tell if boto did it successfully?

Help!
-Matt

Credentials, authorization, authenticating

Matt Hickford

unread,
Oct 23, 2011, 8:22:31 AM10/23/11
to gs-dis...@googlegroups.com
In Python, I checked boto.config.items('Credentials') this has an 'gs_oauth2_refresh_token' in it/.

Google Storage Team

unread,
Oct 24, 2011, 1:32:33 PM10/24/11
to gs-dis...@googlegroups.com
Hi Matt,

The boto library should automatically find and use your $HOME/.boto file. One thing to check: make sure the project you're using is set as your default project for legacy access (at the API console, click on "Storage Access" and verify that it says "This is your default project for legacy access"). When I have that set incorrectly and I follow the create bucket example you referenced, I also get a 403 error.

If that doesn't help, try adding "debug=2" when you instantiate the storage_uri object, like this:

    uri = boto.storage_uri(name, GOOGLE_STORAGE, debug=2)

That will generate some additional debugging information on stdout, which you can then compare with the debug output from an analogous, working gsutil example (via gsutil -D mb <bucket-name>). If that doesn't lead to any further insights, feel free to share any relevant traces with this group but be careful to remove any sensitive info (e.g. authentication tokens, etc.) from any traces you share publicly. 

Hope that helps,

Marc
Google Cloud Storage Team

On Sun, Oct 23, 2011 at 5:22 AM, Matt Hickford <matt.h...@gmail.com> wrote:
In Python, I checked boto.config.items('Credentials') this has an 'gs_oauth2_refresh_token' in it/.

--
You received this message because you are subscribed to the Google Groups "Google Storage for Developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/gs-discussion/-/Wn3mXBL9xrMJ.

To post to this group, send email to gs-dis...@googlegroups.com.
To unsubscribe from this group, send email to gs-discussio...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gs-discussion?hl=en.

Matt Hickford

unread,
Feb 9, 2012, 6:37:16 PM2/9/12
to gs-dis...@googlegroups.com
Hi Marc. Thanks for your reply.
Reply all
Reply to author
Forward
0 new messages