Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9146641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:47:50+00:00 2026-06-17T10:47:50+00:00

When I had my hard-coded access key and secret key present, I was able

  • 0

When I had my hard-coded access key and secret key present, I was able to generate authenticated urls for users to view private files on S3. This was done with the following code:

import hmac
import sha
import urllib
import time

filename = "".join([s3_url_prefix, filename])
expiry = str(int(time.time()) + 3600)
h = hmac.new(
    current_app.config.get("S3_SECRET_KEY", None),
    "".join(["GET\n\n\n", expiry, "\n", filename]),
    sha
)
signature = urllib.quote_plus(base64.encodestring(h.digest()).strip())
return "".join([
    "https://s3.amazonaws.com",
    filename,
    "?AWSAccessKeyId=",
    current_app.config.get("S3_ACCESS_KEY", None),
    "&Expires=",
    expiry,
    "&Signature=",
    signature
])

Which gave me something to the effect of https://s3.amazonaws.com/bucket_name/path_to_file?AWSAccessKeyId=xxxxx&Expires=5555555555&Signature=eBFeN32eBb2MwxKk4nhGR1UPhk%3D. Unfortunately, I am unable to store keys in config files for security reasons. For this reason, I switched over to IAM roles. Now, I get my keys using:

_iam = boto.connect_iam()

S3_ACCESS_KEY = _iam.access_key
S3_SECRET_KEY = _iam.secret_key

However, this gives me the error “The AWS Access Key Id you provided does not exist in our records.”. From my research, I understand that this is because my IAM keys aren’t the actual keys, but instead used with a token. My question therefore, is twofold:

  1. How do I get the token programatically? It doesn’t seem that there is a simple iam property I can use.

  2. How do I send the token in the signature? I believe my signature should end up looking something like “”.join([“GET\n\n\n”, expiry, “\n”, token, filename]), but I can’t figure out what format to use.

Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:47:51+00:00Added an answer on June 17, 2026 at 10:47 am

    There was a change to the generate_url method in https://github.com/boto/boto/commit/99e14f3df039997f54a5377cb6aecc83f22c2670 (June 2012) that made it possible to sign a URL using session credentials. That means you would need to be using a boto version 2.6.0 or later. If you are, you should be able to just do this:

    import boto
    s3 = boto.connect_s3()
    url = s3.generate_url(expires_in=3600, method='GET', bucket='<bucket_name>', key='<key_name>')
    

    What version are you using?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently had a hard drive crashed and lost all of my source code.
I've had a hard time sitting in front of UML and getting value out
I'm using the jQuery plugin for TinyMCE and have had a hard time trying
I have a malformed page to scrape, and have had a hard time getting
I'm new to C# coming from a python background. I've had a hard time
If this was previously talked about, I'm sorry, I had a hard time searching
The hard drive on one of my PCs crashed that had the installers for
First of all, had a hard time figuring out a title, and it's a
Given the following sample XML (here I am showing hard-coded, but normally I load
Had to download Command Line Tools from Apple to get make to work, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.