Download a file from S3 Bucket using boto3 by passing credentials as parameters
<p>As per Boto3 official documentation, we can connect S3 bucket by passing credentials as a parameters. But I am facing issues. </p>

<p><strong>Working Scenario : Hardcoding Key ID &amp; Secret Key</strong></p>

<pre><code>s3r = boto3.resource('s3', aws_access_key_id='XXXXXXXXXXXXXXXXXXXX',
    aws_secret_access_key='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
buck = s3r.Bucket('bucket name')
buck.download_file(filename,filename)
</code></pre>

<p><strong>Non Working Scenario : Passing as parameters</strong></p>

<pre><code>AccessKey = 'XXXXXXXXXXXXXXXXXXXX'
SecretKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
s3r = boto3.resource('s3', aws_access_key_id=AccessKey, aws_secret_access_key=SecretKey)
buck = s3r.Bucket('bucket name')
buck.download_file(filename,filename)
</code></pre>

<p>I am facing below error for non-working scenario.</p>

<pre><code>botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
</code></pre>