Bitcoin Forum
May 10, 2024, 04:05:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Working Through the new MtGox Key & Secret API Authentication Model using C#  (Read 5032 times)
rajasekar1987
Newbie
*
Offline Offline

Activity: 1
Merit: 0


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
1715357137
Hero Member
*
Offline Offline

Posts: 1715357137

View Profile Personal Message (Offline)

Ignore
1715357137
Reply with quote  #2

1715357137
Report to moderator
1715357137
Hero Member
*
Offline Offline

Posts: 1715357137

View Profile Personal Message (Offline)

Ignore
1715357137
Reply with quote  #2

1715357137
Report to moderator
1715357137
Hero Member
*
Offline Offline

Posts: 1715357137

View Profile Personal Message (Offline)

Ignore
1715357137
Reply with quote  #2

1715357137
Report to moderator
The forum strives to allow free discussion of any ideas. All policies are built around this principle. This doesn't mean you can post garbage, though: posts should actually contain ideas, and these ideas should be argued reasonably.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715357137
Hero Member
*
Offline Offline

Posts: 1715357137

View Profile Personal Message (Offline)

Ignore
1715357137
Reply with quote  #2

1715357137
Report to moderator
1715357137
Hero Member
*
Offline Offline

Posts: 1715357137

View Profile Personal Message (Offline)

Ignore
1715357137
Reply with quote  #2

1715357137
Report to moderator
usafinders
Newbie
*
Offline Offline

Activity: 28
Merit: 0


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!