Greetings all. I am having issues connecting to the MtGOX API v2. I keep getting the following error:
"login_error_missing_nonce"
This error is reported in this thread here:
https://bitcointalksearch.org/topic/m.1852502Eventually being solved here:
https://bitcointalksearch.org/topic/m.1853109I have read and re-read that thread over and over and I can't apply that solution to my code. I am coding in Go and have come up with a basic script to call "money/info". Here is the code:
func main() {
// generate data string
t := time.Now()
nonce := t.UnixNano() / 1000
data := fmt.Sprintf("nonce=%d", nonce)
// create the hash data
hashData := []byte("BTCUSD/money/info" + "\x00" + data)
// create the Rest-Sign for the header
secret, _ := base64.StdEncoding.DecodeString(APISecret)
s := hmac.New(sha512.New, secret)
s.Write(hashData)
hmac := s.Sum(nil)
restSign := base64.StdEncoding.EncodeToString(hmac)
// format the data string for the request
postData := strings.NewReader(data)
// create the http connection
client := &http.Client{}
request, _ := http.NewRequest("POST", "https://data.mtgox.com/api/2/BTCUSD/money/info", postData)
// add customer headers
request.Header.Set("User-Agent", "LuckyTime")
request.Header.Set("Rest-Key", APIKey)
request.Header.Set("Rest-Sign", restSign)
request.Header.Set("Accepted-encoding", "GZIP")
// send out request and print response
response, _ := client.Do(request)
defer response.Body.Close()
body, _ := ioutil.ReadAll(response.Body)
fmt.Printf("%s\n", body)
}
APIKey and APISecret are global variables that are properly set. I have adjusted the length of the nonce variable as recommended by the linked thread and nothing changes. I am clearly providing the nonce value. I have tried creating a new API key and secret multiple times so it's not that I messed up a nonce value on a specific key. I have no idea why this isn't working. Any help is most appreciated.