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-PAYLOADThe Authorization header uses a space to separate the signature version from the signature fields. The signature fields are key-value pairs separated by commas.
| Field | Required | Description |
|---|---|---|
OSS4-HMAC-SHA256 | Yes | The signature version. This is the only supported value. |
Credential | Yes | Your access key ID followed by the credential scope, in the format <AccessKeyID>/<date>/<region>/oss/aliyun_v4_request. |
AdditionalHeaders | No | An optional list of additional headers included in the signature. |
Signature | Yes | The computed HMAC-SHA256 signature. |
Note: There is no comma betweenOSS4-HMAC-SHA256andCredential. 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-PAYLOADIf 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
For information about how to use Alibaba Cloud SDKs to construct V4 signature requests automatically, see Overview.
For information about how to calculate the V4 signature manually, see Calculate V4 signature by using OSS SDK for Python.
For information about V1 signature requests, see Overview.