0002-00000205

更新时间:
复制 MD 格式

Problem description

The Credential field is missing from the Authorization header in a V4 signature request.

Causes

When you construct a V4 signature request manually, the Authorization header must include two required fields (Credential and Signature) and one optional field (AdditionalHeaders). If Credential is absent, OSS rejects the request.

Examples

The following request is invalid because the Credential field is missing from the Authorization header:

GET /oss.jpg HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT
Authorization: OSS4-HMAC-SHA256 Signature=18**0a
x-oss-content-sha256: UNSIGNED-PAYLOAD

The Authorization header uses a space to separate the signature version from the signature fields. The signature fields are key-value pairs separated by commas.

FieldRequiredDescription
OSS4-HMAC-SHA256YesThe signature version. This is the only supported value.
CredentialYesYour access key ID followed by the credential scope, in the format <AccessKeyID>/<date>/<region>/oss/aliyun_v4_request.
AdditionalHeadersNoAn optional list of additional headers included in the signature.
SignatureYesThe computed HMAC-SHA256 signature.
Note: There is no comma between OSS4-HMAC-SHA256 and Credential. Commas separate only the signature fields from each other.

Solutions

Add the Credential field to the Authorization header:

GET /oss.jpg HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Tue, 20 Dec 2022 08:48:18 GMT
Authorization: OSS4-HMAC-SHA256 Credential=AK**ID/20221220/us-east-1/oss/aliyun_v4_request,AdditionalHeaders=host,Signature=18**0a
x-oss-content-sha256: UNSIGNED-PAYLOAD

If the request reaches the server but the signature is still invalid, check whether the StringToSign value your client computed matches what the server derived. A mismatch in StringToSign means the signature will not pass, regardless of the Authorization header format.

References