python and boto : 403 accessDenied
Question: 
    import boto
    from boto.s3.connection import S3Connection
    from boto.s3.connection import OrdinaryCallingFormat
    
    conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())
    bucket = conn.get_bucket(file_name)
    print(bucket.name)
    

And the console display:

    
    
    raise err
    boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden
    

I have seen many post about the same problem but I can't figure out how to
solve it... note that I am not the owner of the bucket, but I succeed to
connect and download the file with a gui tool. I need to process it by script
for automation.

EDIT: Succeed to connect, but still struggling... I begin to hesitate to
process it automatically rather than manually ...

    
    
        conn = S3Connection(access_key, secret_key, calling_format=OrdinaryCallingFormat())
    
    bucket = conn.get_bucket(bucket_name, validate=False)
    print('bucket:', bucket)
    print('bucket.name:', bucket.name)
    
    key = bucket.get_key(file_name)
    print("key: {name}\t{size}\t{modified}".format(name = key.name,size = key.size,modified = key.last_modified))
    
    print('bucket.list():',bucket.list(prefix='GA-Exports/Events_3112/DEV'))
    
    for key in bucket.list(prefix='DEV/',delimiter='/'):
        print('bucket list -> key:',key)
    

console :

    
    
    bucket: <Bucket: GA-Exports/Events_3112/>
    bucket.name: GA-Exports/Events_3112/
    key: DEV/EVENTS_3113_120002892.csv.gz   3826    Sat, 16 May 2015 10:05:44 GMT
    bucket.list(): <boto.s3.bucketlistresultset.BucketListResultSet object at 0x0000000004E9F7F0>
    Traceback (most recent call last):
      File "D:\Python\lib\xml\sax\expatreader.py", line 207, in feed
        self._parser.Parse(data, isFinal)
    xml.parsers.expat.ExpatError: no element found: line 1, column 0
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "C:\Users\Francois\OneDrive\IDE\Workspace\eclipse\Python_test\etltest.py", line 31, in <module>
        for key in bucket.list(prefix='DEV/',delimiter='/'):
      File "D:\Python\lib\site-packages\boto\s3\bucketlistresultset.py", line 34, in bucket_lister
        encoding_type=encoding_type)
      File "D:\Python\lib\site-packages\boto\s3\bucket.py", line 472, in get_all_keys
        '', headers, **params)
      File "D:\Python\lib\site-packages\boto\s3\bucket.py", line 406, in _get_all
        xml.sax.parseString(body, h)
      File "D:\Python\lib\xml\sax\__init__.py", line 46, in parseString
        parser.parse(inpsrc)
      File "D:\Python\lib\xml\sax\expatreader.py", line 107, in parse
        xmlreader.IncrementalParser.parse(self, source)
      File "D:\Python\lib\xml\sax\xmlreader.py", line 125, in parse
        self.close()
      File "D:\Python\lib\xml\sax\expatreader.py", line 217, in close
        self.feed("", isFinal = 1)
      File "D:\Python\lib\xml\sax\expatreader.py", line 211, in feed
        self._err_handler.fatalError(exc)
      File "D:\Python\lib\xml\sax\handler.py", line 38, in fatalError
        raise exception
    xml.sax._exceptions.SAXParseException: <unknown>:1:0: no element found
    


Answer: By default, boto will attempt to validate the bucket when you call
`get_bucket` by performing a `HEAD` request on the bucket. You may not have
permission to do this even though you may have permission to retrieve objects
from the bucket. Try this to disable the validation step:

    
    
    bucket = conn.get_bucket(bucket_name, validate=False)
    

Also, make sure you are passing in the name of the bucket. Your example code
is passing in `file_name` which doesn't sound right.

