title: How do I use python to download an S3 file from a link with a signature and expiration?
body: <p>I have a s3 link provided to me by a third-party with the following structure: <code>http://s3.amazonaws.com/bucket_name_possibly/path/to/file_possibly/filename?AWSAccessKeyId=SomeKey&amp;Expires=888888&amp;Signature=SomeCharactersPossiblyHTMLencoded</code></p>
  
  <p>Clicking on the link downloads the file for me. However, in python when I try to use <code>urllib.request.urlretrieve(link_string)</code> on the link I get the error <code>HTTP Error 403: Forbidden</code></p>
  
  <p>I have also tried using boto3 and manually parsing out the bucket_name, key, AWSAccessKeyID as well as the signature(treating it as the AWSSecretAccessKey - I know that this is probably wrong). I setup a client with the credentials and try to run a get_object method. Something similar to below:</p>
  
  <pre><code>client= boto3.client(
    's3',
    aws_access_key_id='AWSACCESSKEY',
    aws_secret_access_key='SomeCharactersPossiblyHTMLencoded',
    config=Config(signature_version='s3v4') # tried with/without this option
  )
  client.get_object(
     Bucket='bucket_name_possibly',
     Key='path/to/file_possibly/filename'
   )
  </code></pre>
  
  <p>The resulting error is <code>An error occurred (SignatureDoesNotMatch) when calling the GetObject operation: The request signature we calculated does not match the signature you provided. Check your key and signing method</code>.</p>
  
  <p>I am stuck, how can I get python to programmatically download the link?</p>