Can i use boto3 anonymously?

With boto I can connect to public S3 buckets without credentials by passing the keyword argument anon= .

 s3 = boto.connect_s3(anon=True) 

Is this possible with boto3 ?

+11
source share
3 answers

Unsubscribe

 import boto3 from botocore.handlers import disable_signing resource = boto3.resource('s3') resource.meta.client.meta.events.register('choose-signer.s3.*', disable_signing) 
+14
source

Yes. Your credentials are used to sign all requests you sent, so you need to configure the client so that it does not perform the signing step at all. You can do it as follows:

 import boto3 from botocore import UNSIGNED from botocore.client import Config s3 = boto3.client('s3', config=Config(signature_version=UNSIGNED)) # Use the client 
+12
source

It seems that none of them work in the current version of boto3 (1.9.168). This hack (thanks to the unfixed github issue on botocore) seems to do the trick:

 client = boto3.client('s3', aws_access_key_id='', aws_secret_access_key='') client._request_signer.sign = (lambda *args, **kwargs: None) 
0
source

Source: https://habr.com/ru/post/1240884/


All Articles