[Python] How to specify credentials when connecting to boto3 S3?

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    On boto I used to specify my credentials when connecting to S3 in such a way:

    import boto
    from boto.s3.connection import Key, S3Connection
    S3 = S3Connection( settings.AWS_SERVER_PUBLIC_KEY, settings.AWS_SERVER_SECRET_KEY )


    I could then use S3 to perform my operations (in my case deleting an object from a bucket).

    With boto3 all the examples I found are such:

    import boto3
    S3 = boto3.resource( 's3' )
    S3.Object( bucket_name, key_name ).delete()


    I couldn't specify my credentials and thus all attempts fail with InvalidAccessKeyId error.

    How can I specify credentials with boto3?

    Continue reading...

Compartilhe esta Página