Boto Exception NoAuthHandler Found

12,534

Few tips:

  • assert in your code, that the values for ID aws_access_key and aws_secret_access_key are not empty. It is likely, you do not have them set at the place you think you have.
  • remove authentication arguments from boto.connect_<something>. This will let boto to use built in authentication handlers and these shall try reading the file, checking environmental variables etc. You will have your code simpler while still being able to provide all what is needed by any of boto authentication methods.
  • my favourit authentication method is to use ini file (usually named boto.cfg) and having BOTO_CONFIG environmental variable set to full path to this file, e.g. to `"/home/javl/.boto/boto.cfg"
  • note, that if you pass any of the authentication parameters to boto.connect_<something> with value null, it will work as boto will check other methods to find the value.
  • since about a year ago, there is an option profile, allowing to refer to specific profile in boto config file. This let me switching to different profiles anywhere in the code.

For more tips and details, see related SO answer

Share:
12,534
Tai
Author by

Tai

Trying to learn objective c ...

Updated on June 04, 2022

Comments

  • Tai
    Tai almost 2 years

    I'm getting the following error:

    File "/Users/tai/Desktop/FlashY/flashy/sniffer/database.py", line 21, in <module>
        import dynamoStorage
    File "/Users/tai/Desktop/FlashY/flashy/sniffer/dynamoStorage.py", line 37, in <module>
        swfTable = Table(decompiled_dynamo_table, connection=dynamoConn)
    File "/Library/Python/2.7/site-packages/boto/dynamodb2/table.py", line 107, in __init__
        self.connection = DynamoDBConnection()
    File "/Library/Python/2.7/site-packages/boto/dynamodb2/layer1.py", line 183, in __init__
        super(DynamoDBConnection, self).__init__(**kwargs)
    File "/Library/Python/2.7/site-packages/boto/connection.py", line 1073, in __init__
        profile_name=profile_name)
    File "/Library/Python/2.7/site-packages/boto/connection.py", line 572, in __init__
        host, config, self.provider, self._required_auth_capability())
    File "/Library/Python/2.7/site-packages/boto/auth.py", line 883, in get_auth_handler
        'Check your credentials' % (len(names), str(names)))
    boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
    

    When I had the auth directly in the file my keys worked so I know the keys are correct.

    I have for awsAccess.py:

    #aswAccess holds the names of the bash environment set keys.
    #used by other classes to create a connection to aws
    aws_access_key_id=os.getenv('AWS_ACCESS_KEY');
    aws_secret_access_key=os.getenv('AWS_SECRET_KEY');
    aws_dynamo_region=os.getenv('DYANAMO_REGION')
    

    and I have for database.py

    #for connecting to aws
    aws_access_key_id=awsAccess.aws_access_key_id
    aws_secret_access_key=awsAccess.aws_secret_access_key
    aws_dynamo_region=awsAccess.aws_dynamo_region
    
    aws_dynamo_table="decompiled_swf_text"
    conn= S3Connection(aws_access_key_id,aws_secret_access_key);
    dynamoConn = boto.connect_dynamodb(aws_access_key_id, aws_secret_access_key)
    dTable = dynamoConn.get_table(aws_dynamo_table)
    

    So I know the keys themselves are correct.

    I have a .bash_profile file that looks like this (**indicating removed, also I tried with and without ""'s):

    export AWS_ACCESS_KEY="myAccessKey**"
    
    export AWS_SECRET_KEY="mySecretKey**"
    
    export DYNAMO_REGION="us-east"
    

    I run source ~/.bash_profile, and then tried running but get the error. I can't see why importing would alter the impact of the same key string.

  • Tai
    Tai almost 10 years
    Hm interesting. I added assert statements just to check and realized that aws_dynamo_region is None... hmm thanks for the link. Can you explain what you mean by remove authentication arguments from boto.connect_<something> as in boto.connect(..)?
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years
    @TaiHirabayashi By removing I mean changing dynamoConn = boto.connect_dynamodb(aws_access_key_id, aws_secret_access_key) to dynamoConn = boto.connect_dynamodb(). This shall give boto good chance to try it's best to read credentials from config file or from environmental variables. This way my code get much simpler (a lot of credentials handling got removed) and all is resolved at the time of starting by BOTO_CONFIG env variable, variables for key and access key or these globally available methods.