Author

Topic: Issue Connecting To MtGOX API v2 (Read 888 times)

newbie
Activity: 2
Merit: 0
May 21, 2013, 03:39:42 PM
#3
I finally managed to figure it out!

You have to set the "Content-Type" header to "application/x-www-form-urlencoded"

Worked for me at least...
newbie
Activity: 2
Merit: 0
May 20, 2013, 11:52:53 AM
#2
I'm having exactly the same issue, also using Go.

Did you manage to figure it out?

Cheers
newbie
Activity: 14
Merit: 0
April 26, 2013, 03:05:39 PM
#1
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.1852502

Eventually being solved here:
https://bitcointalksearch.org/topic/m.1853109

I 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:

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.
Jump to: