diff --git a/docs/backends/gcloud.rst b/docs/backends/gcloud.rst index 962298eb..b5535a49 100644 --- a/docs/backends/gcloud.rst +++ b/docs/backends/gcloud.rst @@ -219,3 +219,12 @@ Settings It supports `timedelta`, `datetime`, or `integer` seconds since epoch time. Note: The maximum value for this option is 7 days (604800 seconds) in version `v4` (See this `Github issue `_) + +``sa_email`` or ``GS_SA_SIGNING_EMAIL`` + + default: ``''`` + + This is the signing email if it is not fetched from the credentials. Or if you wish to sign the signed urls with a different service_account. + + As above please note that, Default Google Compute Engine (GCE) Service accounts are + `unable to sign urls `_. diff --git a/storages/backends/gcloud.py b/storages/backends/gcloud.py index 77b3e144..9b529620 100644 --- a/storages/backends/gcloud.py +++ b/storages/backends/gcloud.py @@ -1,5 +1,4 @@ import gzip -import logging import io import mimetypes from datetime import timedelta @@ -37,7 +36,6 @@ CONTENT_ENCODING = "content_encoding" CONTENT_TYPE = "content_type" -_LOGGER = logging.getLogger(__name__) class GoogleCloudFile(CompressedFileMixin, File): @@ -155,7 +153,6 @@ def client(self): credentials.refresh(requests.Request()) if not hasattr(credentials, "service_account_email"): credentials.service_account_email = self.sa_email - _LOGGER.debug(f"Signing email: {credentials.service_account_email}") self.credentials = credentials if self._client is None: self._client = Client(project=project_id, credentials=self.credentials) @@ -330,9 +327,13 @@ def url(self, name, parameters=None): quoted_name=_quote(name, safe=b"/~"), ) elif not self.custom_endpoint: - return blob.generate_signed_url(**self.signed_url_extra()) + return blob.generate_signed_url( + expiration=self.expiration, + **self.signed_url_extra() + ) else: return blob.generate_signed_url( + expiration=self.expiration, api_access_endpoint=self.custom_endpoint, **self.signed_url_extra() )