0002-00000301

更新时间:
复制 MD 格式

Problem description

The request is missing the Expires field, which is required when using query string authentication with the Amazon S3-compatible API.

Causes

When you sign a request using query string authentication (S3-compatible mode), OSS requires an Expires parameter in the query string. This parameter tells OSS when the signed URL expires. If it is absent, OSS cannot validate the signature and returns a timeout error.

Examples

The following request is missing Expires:

GET /test.txt?AWSAccessKeyId=nz2p****&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-s3-compat: true
ParameterRoleMissing in example
AWSAccessKeyIdIdentifies the access key used to sign the requestNo
ExpiresUNIX timestamp indicating when the signed URL expiresYes
SignatureHMAC signature computed over the requestNo

The Expires value is a UNIX timestamp — the number of seconds elapsed since January 1, 1970 00:00:00 UTC. If OSS receives the request after this timestamp, it rejects the request with a timeout error. For example, if the current time is 1141889060 and you want the URL to be valid for 60 seconds, set Expires to 1141889120.

Solutions

Add the Expires parameter to the query string with a valid UNIX timestamp:

GET /test.txt?AWSAccessKeyId=nz2p****&Expires=1141889120&Signature=vjbyPxybdZaNmGa%2ByT272YEAiv**** HTTP/1.0
Date: Tue, 20 Dec 2022 08:48:18 GMT
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
x-oss-s3-compat: true

To avoid constructing signed URLs manually, use Amazon S3 SDKs to generate requests. For details, see Use Amazon S3 SDKs to access OSS.