Bitcoin Forum
December 08, 2016, 02:41:46 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 [2]  All
  Print  
Author Topic: Working Through the new MtGox Key & Secret API Authentication Model using C#  (Read 4743 times)
rajasekar1987
Newbie
*
Offline Offline

Activity: 1


View Profile
August 26, 2012, 06:06:20 AM
 #21

       THe following Code is not working , Pls help what I have missed out here, Always getting following msg

"error":"You cannot login to the API with just a login and password".


       Dim ApiKey = "TTTTTTTTTTTT"
       Dim ApiSecretKey ="9o1AuLHkNP5fx8lxfPpzmWtjwjuwUlHL3qVfInTmjYrFjQ=="
       Dim url = "https://mtgox.com/code/cancelOrder.php"       
       Dim params
       
        UserName = "raj"
        Password = "raj"
        Dim orderID = "1111011"
        Dim ordertype = "clos"

        Dim strUrl = url

        Dim req As Net.HttpWebRequest = System.Net.HttpWebRequest.Create(strUrl)

        req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"

        req.Accept = " Application / json"

     
            req.Headers.Add("key", ApiKey)
            params.Add(Tuple.Create("nonce", DateTime.Now.Ticks.ToString()))
            params.add(tuple.Create("name", UserName))
            params.add(tuple.Create("pass", Password))
            params.add(tuple.Create("orderID", orderID))
            params.add(tuple.Create("orderType", ordertype))



        If params.Count Then
            req.AllowWriteStreamBuffering = True
            req.Method = "POST"
            req.ContentType = "application/x-www-form-urlencoded"
           
Dim postSB As New System.Text.StringBuilder()

For Each param In params
                If postSB.Length Then postSB.Append("&")
                postSB.Append(param.Item1)
                postSB.Append("=")
                postSB.Append(param.Item2)
Next

Dim postBin = System.Text.Encoding.ASCII.GetBytes(postSB.ToString())


 If authRequired Then
                Dim hmac = System.Security.Cryptography.HMACSHA512.Create()
                hmac.Key = Convert.FromBase64String(ApiSecretKey)
                Dim hash = hmac.ComputeHash(postBin)
                req.Headers.Add("secret", Convert.ToBase64String(hash))
 End If

 req.GetRequestStream.Write(postBin, 0, postBin.Length)

 End If



Dim response = req.GetResponse.GetResponseStream()
   
Dim reader As IO.StreamReader = New IO.StreamReader(response)
   
MsgBox(reader.ReadToEnd)

End Sub
1481208106
Hero Member
*
Offline Offline

Posts: 1481208106

View Profile Personal Message (Offline)

Ignore
1481208106
Reply with quote  #2

1481208106
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481208106
Hero Member
*
Offline Offline

Posts: 1481208106

View Profile Personal Message (Offline)

Ignore
1481208106
Reply with quote  #2

1481208106
Report to moderator
1481208106
Hero Member
*
Offline Offline

Posts: 1481208106

View Profile Personal Message (Offline)

Ignore
1481208106
Reply with quote  #2

1481208106
Report to moderator
1481208106
Hero Member
*
Offline Offline

Posts: 1481208106

View Profile Personal Message (Offline)

Ignore
1481208106
Reply with quote  #2

1481208106
Report to moderator
usafinders
Newbie
*
Offline Offline

Activity: 29


View Profile
May 08, 2013, 12:00:13 PM
 #22

Oh and the great part if I accidentally posted the apiKey and apiSecret is I could go to MtGox and delete the old and create a new without ever worrying.
Pages: « 1 [2]  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!