gateio / gateapi-go

107 stars 39 forks source link

{"label":"INVALID_SIGNATURE","message":"Signature mismatch"} #3

Closed lijutang closed 4 years ago

lijutang commented 4 years ago

你好,签名不匹配 源码:

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 4 years ago

可以帮我看一下是怎么回事吗

revilwang commented 4 years ago

func gate.requestUrl(string) (string, string, error) 这个函数里的具体实现是怎样的?

SDK 里已经封装了具体的签名生成方式: https://github.com/gateio/gateapi-go/blob/master/client.go#L274

lijutang commented 4 years ago

你好,我绑定了IP ,api还是显示,{"label":"IP_FORBIDDEN","message":"Request IP not in whitelist"}

revilwang commented 4 years ago

这个错误只有在设置了白名单 IP,并且客户端的公网 IP 与设置的 IP 不一致才会出现

lijutang commented 4 years ago

{"label":"USER_NOT_FOUND"} 出现这种情况是什么原因?

revilwang commented 4 years ago

请参考常见问题:

https://www.gatecn.io/docs/apiv4/zh_CN/index.html#0adb1147b3

本 issue 已经超出验签的问题,其他问题请开新的 issue,本 issue 关闭