华为App Gallery API上传APK报错:签名验证不匹配
华为App Gallery API上传APK/AAB时签名不匹配问题
问题现象
通过Bash脚本调用华为App Gallery API上传APK/AAB文件,已成功获取上传URL及所需参数,但执行文件上传步骤时返回签名不匹配错误:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
操作过程
- 按照《Obtaining the File Upload URL》文档要求,设置移除冒号后的sha256参数:
sha256="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
- 调用API获取上传URL,将响应存入
old.json并解析上传所需参数:
curl -s -H 'Content-Type: application/json' -H "Authorization: Bearer $token" -H "client_id: $clientid" -X GET 'https://connect-api.cloud.huawei.com/api/publish/v2/upload-url/for-obs?...' | jq . > old.json url=$(cat old.json | jq -r .urlInfo.url) authorization=$(cat old.json | jq -r .urlInfo.headers.Authorization) amzcontent256=$(cat old.json | jq -r '.urlInfo.headers."x-amz-content-sha256"') amz256date=$(cat old.json | jq -r '.urlInfo.headers."x-amz-date"') hosttype=$(cat old.json | jq -r .urlInfo.headers.Host) useragent=$(cat old.json | jq -r '.urlInfo.headers."user-agent"') contentyp=$(cat old.json | jq -r '.urlInfo.headers."Content-Type"')
- 使用解析出的参数发起文件上传请求:
curl -H 'Content-Type: application/octet-stream' -H "x-amz-content-sha256:$amzcontent256" -H "x-amz-date:$amz256date" -H "Host:$hosttype" -H "user-agent:$useragent" -H "Authorization:$authorization" -F 'file=@/Users/app1/apkfolder/test.apk' -X PUT $uploadurl
上传响应错误
return (<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method. )
已确认sha256变量值与App Gallery中目标应用的sha256指纹完全一致,但仍出现该签名错误,怀疑shaKey设置环节存在问题,求排查解决方法。
内容的提问来源于stack exchange,提问作者Selimcan Kacar
相关产品推荐
相关产品推荐

