亚马逊 MWS - 计算的请求签名与提供的签名不匹配 [英] Amazon MWS - request signature calculated does not match the signature provided
本文介绍了亚马逊 MWS - 计算的请求签名与提供的签名不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从 https://mws.amazonservices.com/ 获取以下错误消息:
Getting the following error message from https://mws.amazonservices.com/:
<Type>Sender</Type>
<Code>SignatureDoesNotMatch</Code>
−
<Message>
The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
</Message>
这是我用来计算请求的 VB.net 代码.出于安全原因,我删除了 SecretKey 和 AWSAccessKeyId.
Here is the VB.net code I am using to calculate the request. I have removed the SecretKey and AWSAccessKeyId for security reasons.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sURL As String = "https://mws.amazonservices.com/"
Dim sRequest As String = ""
sRequest &= "Acknowledged=" & Server.UrlEncode("false")
sRequest &= "&Action=" & Server.UrlEncode("GetReportList")
sRequest &= "&AWSAccessKeyId=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&Marketplace=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&Merchant=" & Server.UrlEncode("REMOVED-FOR-SECURITY")
sRequest &= "&SignatureMethod=" & Server.UrlEncode("HmacSHA256")
sRequest &= "&SignatureVersion=" & Server.UrlEncode("2")
sRequest &= "&Timestamp=" & Server.UrlEncode(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssCST"))
sRequest &= "&Version=" & Server.UrlEncode("2009-01-01")
Dim StringToSign As String = "GET
" & "mws.amazonservices.com
" & "/
" & sRequest
sRequest &= "&Signature=" & Server.UrlEncode(HashString(StringToSign))
Response.Write("<a href=""" & sURL & "?" & sRequest & """>Click here</a>")
End Sub
Public Shared Function HashString(ByVal StringToHash As String) As String
Dim myEncoder As New System.Text.UTF8Encoding
Dim Key() As Byte = myEncoder.GetBytes("REMOVED-FOR-SECURITY")
Dim XML() As Byte = myEncoder.GetBytes(StringToHash)
Dim myHMACSHA256 As New System.Security.Cryptography.HMACSHA256(Key)
Dim HashCode As Byte() = myHMACSHA256.ComputeHash(XML)
Return Convert.ToBase64String(HashCode)
End Function
推荐答案
如果您在开始阅读一些 Amazon 文档后从 Google 登陆这里,您很可能会看到上面的请求签名"错误由于您的秘密访问密钥上无意中的前导或尾随空格.先检查一下!
If you are landing here from Google after starting to work through some of the Amazon documentation, it's quite likely that you're seeing the 'request signature' error above due to a inadvertent leading or trailing space on your secret access key. Check that first!
这篇关于亚马逊 MWS - 计算的请求签名与提供的签名不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文