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 8201799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:56:14+00:00 2026-06-07T06:56:14+00:00

I would like to know how to create a signed URL for cloudfront. The

  • 0

I would like to know how to create a signed URL for cloudfront. The current working solution is unsecured, and I would like to switch the system to secure URL’s.

I have tried using Boto 2.5.2 and Django 1.4

Is there a working example on how to use the boto.cloudfront.distribution.create_signed_url method? or any other solution that works?

I have tried the following code using the BOTO 2.5.2 API

def get_signed_url():
    import boto, time, pprint
    from boto import cloudfront
    from boto.cloudfront import distribution
    AWS_ACCESS_KEY_ID = 'YOUR_AWS_ACCESS_KEY_ID'
    AWS_SECRET_ACCESS_KEY = 'YOUR_AWS_SECRET_ACCESS_KEY'
    KEYPAIR_ID = 'YOUR_KEYPAIR_ID'
    KEYPAIR_FILE = 'YOUR_FULL_PATH_TO_FILE.pem'
    CF_DISTRIBUTION_ID = 'E1V7I3IOVHUU02'
    my_connection = boto.cloudfront.CloudFrontConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    distros = my_connection.get_all_streaming_distributions()
    oai = my_connection.create_origin_access_identity('my_oai', 'An OAI for testing')
    distribution_config = my_connection.get_streaming_distribution_config(CF_DISTRIBUTION_ID)
    distribution_info = my_connection.get_streaming_distribution_info(CF_DISTRIBUTION_ID)
    my_distro = boto.cloudfront.distribution.Distribution(connection=my_connection, config=distribution_config, domain_name=distribution_info.domain_name, id=CF_DISTRIBUTION_ID, last_modified_time=None, status='Active')

    s3 = boto.connect_s3()
    BUCKET_NAME = "YOUR_S3_BUCKET_NAME"
    bucket = s3.get_bucket(BUCKET_NAME)
    object_name = "FULL_URL_TO_MP4_ECLUDING_S3_URL_DOMAIN_NAME EG( my/path/video.mp4)"
    key = bucket.get_key(object_name)
    key.add_user_grant("READ", oai.s3_user_id)

    SECS = 8000
    OBJECT_URL = 'FULL_S3_URL_TO_FILE.mp4'
    my_signed_url = my_distro.create_signed_url(OBJECT_URL, KEYPAIR_ID, expire_time=time.time() + SECS, valid_after_time=None, ip_address=None, policy_url=None, private_key_file=KEYPAIR_FILE, private_key_string=KEYPAIR_ID)

Everything seems fine until the method create_signed_url. It returns an error.

Exception Value: Only specify the private_key_file or the private_key_string not both
  • 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-07T06:56:17+00:00Added an answer on June 7, 2026 at 6:56 am

    Omit the private_key_string:

    my_signed_url = my_distro.create_signed_url(OBJECT_URL, KEYPAIR_ID,
            expire_time=time.time() + SECS, private_key_file=KEYPAIR_FILE)
    

    That parameter is used to pass the actual contents of the private key file, as a string. The comments in the source explain that only one of private_key_file or private_key_string should be passed.

    You can also omit all the kwargs which are set to None, since None is the default.

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

Sidebar

Related Questions

I would like to know how to create a linked list of linked lists.
i would like to know how to create a hidden type input box and
I would like to know how to create a computed observable array. In my
I would like to know how to create a php function that can be
I would like to know how to create a rounded corners on a table
Hi I would like to know how to create a dll that is written
I'm an amateur web developer and I would like to know how to create
I would like to know how can I create a regexp to match the
I would like to know a way to create an XML file using MySQL
I would like to know if there is a method to create share buttons

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.