Bitcoin Forum
November 25, 2017, 02:35:21 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
   Home   Help Search Donate Login Register  
Pages: « 1 [2]  All
Author Topic: Working Through the new MtGox Key & Secret API Authentication Model using C#  (Read 4953 times)
Offline Offline

Activity: 1

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

       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 = ""       
       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("&")

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)

End Sub
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Offline Offline

Activity: 28

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

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
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!