{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}
Closed this issue · 6 comments
lijutang commented
你好,签名不匹配
源码:
func (gate *GateioTrade) gen_sign(body *bytes.Buffer, path, method string) {
h := sha512.New()
if body != nil {
h.Write(body.Bytes())
}
hashedPayload := hex.EncodeToString(h.Sum(nil))
t := strconv.FormatInt(time.Now().Unix(), 10)
rawQuery, Path, err := gate.requestUrl(path)
if err != nil {
msg := fmt.Sprintf("%s\n%s\n%s\n%s\n%s", method, Path, rawQuery, hashedPayload, t)
mac := hmac.New(sha512.New, []byte(gate.APISecret))
mac.Write([]byte(msg))
sign := hex.EncodeToString(mac.Sum(nil))
headerParams := make(map[string]string)
headerParams["KEY"] = gate.APIKey
headerParams["SIGN"] = sign
headerParams["Timestamp"] = t
}
}
lijutang commented
可以帮我看一下是怎么回事吗
revilwang commented
func gate.requestUrl(string) (string, string, error)
这个函数里的具体实现是怎样的?
SDK 里已经封装了具体的签名生成方式: https://github.com/gateio/gateapi-go/blob/master/client.go#L274
lijutang commented
你好,我绑定了IP ,api还是显示,{"label":"IP_FORBIDDEN","message":"Request IP not in whitelist"}
revilwang commented
这个错误只有在设置了白名单 IP,并且客户端的公网 IP 与设置的 IP 不一致才会出现
lijutang commented
{"label":"USER_NOT_FOUND"} 出现这种情况是什么原因?
revilwang commented
请参考常见问题:
https://www.gatecn.io/docs/apiv4/zh_CN/index.html#0adb1147b3
本 issue 已经超出验签的问题,其他问题请开新的 issue,本 issue 关闭