I'm using signedUrl in a PHP App Engine on Goolge Cloud to get the https:// link of stored files in firebase storage using the following code snippet:
$url = $object->signedUrl(
new \DateTime('15 min'),
[
'version' => 'v4',
]
);
So the generated url is valid for 15 minutes. Calling this url after 15 minutes shows the following message in the browser:
<Error>
<Code>ExpiredToken</Code>
<Message>The provided token has expired.</Message>
<Details>Request signature expired at: 2021-07-16T11:29:51+00:00</Details>
</Error>
Is there a possibility to provide a custom error html page for this case? I've tried using
error_handlers:
- file: default_error.html
in my app.yaml file but it doesn't work.
Setting an error in app.yaml does not work, because the error is being generated by GCS, not GAE.
GCS does not provide a way to customize 403 error. If you need this, you will need something in front of GCS to provide the error to users. For example check signature & redirect as John suggests or create a GAE endpoint that does a GCS fetch and then either streams the result to the client or displays a 403.