title: Python Boto3: Error when trying to download files from AWS S3
body: <p>Helllo, </p>
  
  <p>I am trying to download all the files from a S3 bucket that is extremely large. I am connecting to the S3 like this:</p>
  
  <pre><code>client = boto3.client('s3', 
  aws_access_key_id=tempCredentials.credentials.access_key,
  aws_secret_access_key = tempCredentials.credentials.secret_key,                                 
  aws_session_token=tempCredentials.credentials.session_token)
  </code></pre>
  
  <p>From this, I do: </p>
  
  <pre><code># This is going to go through and fill in the dictionary with keys 
  from the buckets as specified above 
  paginator = client.get_paginator("list_objects")
  page_iterator = paginator.paginate(Bucket=bucket["Name"])
  l = 0
  # We are going to have an list that will hold all the keys 
  key_list = []
  for i in page_iterator:
      c = i["Contents"]
      for j in c:
            key_list.append(j["Key"])
      for j in key_list:
          download(bucket["Name"], j, "/Users/ahussain/Desktop/S3_Scrubber/" + file_name_helper(j), client)
  </code></pre>
  
  <p>Where, my download function as: </p>
  
  <pre><code> def download (bucket_name, key, path, client):
      key_name = key 
      print("Dowloading %s..." % str(key))
      client.download_file(bucket_name, key, path)
      print("Download of %s complete!" % str(key))
      return key_name
  </code></pre>
  
  <p>What happens is that I go through the bucket successfully and download a good amount of keys, but after a while the program stops downloading keys and gives me this error: </p>
  
  <pre><code>botocore.exceptions.ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request
  </code></pre>
  
  <p>My guess is that my session expired since I am using an MFA to access this S3, but I am unsure. Has anyone ever run into this error before? </p>