Re: [gs-discussion] boto.exception.NoAuthHandlerFound: No handler was ready to authenticate

1,930 views
Skip to first unread message

Mike Schwartz (Google Storage Team)

unread,
Sep 28, 2012, 6:56:03 PM9/28/12
to gs-dis...@googlegroups.com
Hi Warren,

Are you running this program from a shell that has your HOME environment set to point to your home directory (which is needed so it finds your ~/.boto file)? You can determine this by adding this to your program:

  import os; print os.environ['HOME']

The HOME environment is probably not your home directory if you're running this program in a web server or from a cron job, for example. In situations like that you can add this before the 'import boto' statement:

os.environ['BOTO_CONFIG'] = '/path_to_your_dot_boto_file'

Mike


On Fri, Sep 28, 2012 at 3:36 PM, Warren R. <warre...@gmail.com> wrote:
Hi I am using macosx, and gsutil is working just fine (i did "gsutil config" etc). I definitely have a ~/.boto file, but I am having trouble getting python to work with gcs. I am getting:

boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV1Handler'] Check your credentials

As a test, I am trying to (derived from the "Python Library" example):

import boto
GOOGLE_STORAGE = 'gs'

if __name__ == "__main__":

    uri = boto.storage_uri('', GOOGLE_STORAGE)
    for bucket in uri.get_all_buckets():
        print bucket.name

Any thoughts are much appreciated. Thanks

--
 
 

Warren R.

unread,
Sep 28, 2012, 7:35:16 PM9/28/12
to gs-dis...@googlegroups.com
Didn't quite realize what the 

from oauth2_plugin import oauth2_plugin

A comment in that example would be helpful. Now I get:

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

Trying to figure out how to provide it.

Warren R.

unread,
Sep 28, 2012, 7:51:09 PM9/28/12
to gs-dis...@googlegroups.com
Sorry on that last post I meant to say Didn't quite realize why i needed that import. My boto config was setup to use oauth2 instead of HMAC.

I also fixed the missing projectID by finding (and clicking) the magical gray button at the bottom of https://code.google.com/apis/console/

That will make a project "default project for interoperable access".

Things seem to be working nicely now.

Mike Schwartz (Google Storage Team)

unread,
Sep 28, 2012, 7:53:21 PM9/28/12
to gs-dis...@googlegroups.com
Warren,

Glad you figured it out. I didn't realize in your previous question that you wanted to use OAuth2. I thought you were purposefully using HMAC auth.

You need to import oauth2_plugin before the first time you perform a request that require auth, to cause the boto pluggable auth mechanism to know about (and then use) that auth handler.

Setting a default project ID from the APIs console works. The other option would be to to provide the project ID by populating the x-goog-project-id header (which you can pass in the optional headers parameter in the various StorageUri interfaces).

Mike



--
 
 

Reply all
Reply to author
Forward
0 new messages