Orientação para assinatura de fornecedor terceirizado

Saiba como criar assinaturas de provedores de pagamento terceirizados.

To generate a successful signature, follow the instructions that are documented in the RFC 9421 specification. Note that there are aspects of the signature generation that Amazon enforces for TPPs making SP-API requests. These are documented in the following sections.

Componentes de assinatura

RFC 9421 describes the process of communicating which HTTP message components are signed in a request. You must include the following message components when you generate a signature.

📘

Observação

A não inclusão dos seguintes componentes resulta em uma falha na verificação da assinatura. Você pode adicionar esses componentes em qualquer ordem.

Campos HTTP (cabeçalhos de mensagens)

CabeçalhoDescrição
x-amz-access-tokenO token de acesso LWA usado para fazer a solicitação.
x-amzn-content-digestO resumo sha-256 da carga útil da solicitação. Para solicitações sem carga útil, crie o resumo sha-256 em um esvaziam corda.

For additional information, refer to HTTP Fields.

Componentes derivados

ComponentDescrição
@methodO método HTTP da solicitação. O valor deve estar em maiúsculas (por exemplo GET, POST).
@queryThe normalized query string that is defined by the URI and includes the leading ? character.
If the request doesn’t have a query, you must populate the component value with ? when you create the signature base mentioned in RFC 9421.
The value must be derived after you perform all the necessary encoding, such as Percentile-Encoding. Any further modifications you make to queryString, which are not included when you create the signature, cause signature failure.

For additional information, refer to Derived Components.

Parâmetros de assinatura

ParâmetroDescrição
createdUm carimbo de data/hora da época em segundos.
Se o created A época aponta para um tempo superior a cinco minutos no momento em que a solicitação é recebida, a assinatura é considerada expirada e a chamada é negada.
algAn algorithm that you use to sign the signature base.
The value for alg must be PS512. For additional details, refer to Signing algorithm.

For additional information, refer to Signature Parameters.

🚧

Atenção

Todos os valores do cabeçalho da solicitação diferenciam maiúsculas de minús Se houver alguma incompatibilidade entre maiúsculas e minúsculas, sua verificação de assinatura falhará.

Etiqueta de assinatura

RFC 9421 allows multiple signatures within the same header (to disambiguate, use signature labels). SP-API only uses one signature, which is identified by the x-amzn-psd2 signature label. You must use it in the Signature and Signature-Input headers to identify PSD2-related information.

algoritmo de assinatura

A signature is generated on the signature base string that is created when you complete the steps in RFC 9421. After you generate your signature base string, you must use the private key that is associated with your electronic NCA Certificate to sign the request with the PS512 algorithm. This algorithm is the only one that is currently supported for SP-API requests.

The certificate that is associated with the private key you used in the signature must be passed as a header (x-amzn-psd2-certificate) in your SP-API request. The certificate must be a PEM-formatted string in Base64 encoding that begins with -----BEGIN CERTIFICATE----- and ends with -----END CERTIFICATE-----.

Se você usar qualquer caractere não permitido no certificado, sua solicitação da SP-API será negada. Você deve usar somente certificados destinados a assinar solicitações HTTP emitidas por Provedores de Serviços de Confiança Qualificados (QTSPs).

🚧

Atenção

O certificado que você usa deve estar associado ao identificador da organização que você forneceu em seu registro de desenvolvedor. Se houver uma incompatibilidade, sua solicitação será negada.

Resposta de erro

Se a validação da assinatura da solicitação falhar, você receberá um erro 403 que contém informações adicionais no corpo. Por exemplo:

{ "errors": [ { "code": "Unauthorized", "message": "Access to requested resource is denied.", "details": "Reason for error." } ] }

A seguir está uma lista de valores possíveis para o details campo:

Mensagem de erroDescrição
TPP certificate required but missing from requestO x-amzn-psd2-certificate o cabeçalho está ausente.
TPP certificate has invalid formatO certificado fornecido não está no formato PEM válido.
Content Digest header required but missing from requestO cabeçalho da solicitação x-amzn-content-digest está ausente.
Invalid Content DigestO resumo do conteúdo não pôde ser verificado ou você usou um algoritmo incompatível. Somente o SHA-256 é suportado.
Signature-Input header required but not presentedO Signature-Input o cabeçalho da solicitação está ausente.
Signature-Input header is invalidO Signature-Input o valor do cabeçalho não segue a especificação RFC 9421.
Request PSD2 Signature is InvalidAssinatura inválida. Isso pode ter várias causas, como usar a chave privada ou o certificado incorreto ou um erro de digitação.
Signature header is required but not presentedO Signature o cabeçalho da solicitação está ausente.

Exemplo de assinatura

O exemplo a seguir é uma string base de assinatura que contém todos os componentes necessários:

"x-amz-access-token": Atza|IgEBIN... "x-amzn-content-digest": sha-256=:fadf3qr3TAFASEG3234gADA+krdzMzYayg4YFig=: "@method": POST "@query": ?key2=value2&key1=value1 "@signature-params": ("x-amz-access-token" "x-amzn-content-digest" "@method" "@query");created=1720137600;alg="PS512";

O associado Signature-Input cabeçalho é:

Signature-Input: x-amzn-psd2=("x-amz-access-token" "x-amzn-content-digest" "@method" "@query");created=1720137600;alg="PS512"

O exemplo a seguir é um cabeçalho de assinatura que tem a Signature rótulo:

Signature: x-amzn-psd2=:cyqStwls2k3Xs8SSzDvDhxWEc_P0dNxV5I6Tp... :

Esta página ajudou você?