Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: streamline docs for c.g.c migration #876

Merged
merged 7 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions google/cloud/storage/_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,11 @@ def generate_signed_url_v2(
.. note::
If you are on Google Compute Engine, you can't generate a signed URL.
Follow `Issue 922`_ for updates on this. If you'd like to be able to
generate a signed URL from GCE, you can use a standard service account
from a JSON file rather than a GCE service account.
If you'd like to be able to generate a signed URL from GCE, you can use a
standard service account from a JSON file rather than a GCE service account.
See headers `reference`_ for more details on optional arguments.
.. _Issue 922: https://github.com/GoogleCloudPlatform/\
google-cloud-python/issues/922
.. _reference: https://cloud.google.com/storage/docs/reference-headers
See headers [reference](https://cloud.google.com/storage/docs/reference-headers)
for more details on optional arguments.
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: Credentials object with an associated private key to
Expand Down Expand Up @@ -382,6 +378,8 @@ def generate_signed_url_v2(
elements_to_sign.append(canonical.resource)
string_to_sign = "\n".join(elements_to_sign)

# If you are on Google Compute Engine, you can't generate a signed URL.
# See https://github.com/googleapis/google-cloud-python/issues/922
# Set the right query parameters.
if access_token and service_account_email:
signature = _sign_message(string_to_sign, access_token, service_account_email)
Expand Down Expand Up @@ -446,16 +444,11 @@ def generate_signed_url_v4(
.. note::
If you are on Google Compute Engine, you can't generate a signed URL.
Follow `Issue 922`_ for updates on this. If you'd like to be able to
generate a signed URL from GCE, you can use a standard service account
from a JSON file rather than a GCE service account.
See headers `reference`_ for more details on optional arguments.
.. _Issue 922: https://github.com/GoogleCloudPlatform/\
google-cloud-python/issues/922
.. _reference: https://cloud.google.com/storage/docs/reference-headers
If you'd like to be able to generate a signed URL from GCE,you can use a
standard service account from a JSON file rather than a GCE service account.
See headers [reference](https://cloud.google.com/storage/docs/reference-headers)
for more details on optional arguments.
:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: Credentials object with an associated private key to
Expand Down Expand Up @@ -543,6 +536,8 @@ def generate_signed_url_v4(
request_timestamp = _request_timestamp
datestamp = _request_timestamp[:8]

# If you are on Google Compute Engine, you can't generate a signed URL.
# See https://github.com/googleapis/google-cloud-python/issues/922
client_email = service_account_email
if not access_token or not service_account_email:
ensure_signed_credentials(credentials)
Expand Down
Loading