I couldn't find a simple example on how to implement Google Cloud Storage Signed Urls on Google App Engine with Python. Please write a step by step guide. :)
How to Create Google Cloud Storage Signed Urls on App Engine Python
3.4k Views Asked by Peter Korinek TellusTalk AtThere are 3 best solutions below

I created this repo: https://github.com/voscausa/appengine-gcs-signed-url
Using GAE Pyrthon app_identity.get_service_account_name()
and app_identity.sign_blob()
makes creating signed url's very easy, without using a PEM key. The app shows how to download a GCS file.
But if you use the SDK to test the app, you have to use:
- --appidentity_email_address
- --appidentity_private_key_path
because creating a signed url is not part of the GCS client.

The other solutions work but there is a simpler way using generate_signed_url. This method does the same thing as @voscausa's answer but is less tedious and has custom exceptions and support for other environments.
def sign_url(obj, expires_after_seconds=60):
client = storage.Client()
default_bucket = '%s.appspot.com' % app_identity.get_application_id()
bucket = client.get_bucket(default_bucket)
blob = storage.Blob(obj, bucket)
expiration_time = int(time.time() + expires_after_seconds)
url = blob.generate_signed_url(expiration_time)
return url
What vascausa said regarding local development server testing
But if you use the SDK to test the app, you have to use:
--appidentity_email_address
--appidentity_private_key_path
because creating a signed url is not part of the GCS client.
still holds.
Here's how we made it work:
Step 1: Get p12 file/certificate
Download p12 file from https://console.developers.google.com/ “APIs & auth / Credentials” tab.
Step 2: Convert p12 file to DER format
Find a Linux computer open and connect using Terminal Command: openssl pkcs12 -in -nodes -nocerts > # The current Google password for the p12 file is
notasecret
Command: openssl rsa -in -inform PEM -out -outform DER
Step 3: Convert DER file to base64 encoded string
Python console:
Copy and paste into App engine script.
Step 4: Enable PyCrypto in AppEngine
app.yaml must have a line to enable PyCrypto:
Step 5: Python code to create Signed URL
Sources
How to get the p12 file.
Signing instructions.
Inspiration for how to sign the url.