Announcement

Collapse
No announcement yet.

Non-interactive login using VBA question

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Hi guys,

    I am trying to implement this code. It would save my day if I could make this work! Thanks for sharing it.

    It seems I managed to have my certificate registered by Windows. I don't get the complaint "A certificate is required to complete authentication". I suppose I am good with it (although I did do anything related to p12...).

    However, now I get the dreadful message on send:
    Method 'Send' of object 'IWinHttpRequest' failed

    Any clue as to what is going wrong?

    Comment


      #17
      p12 was the key.

      OK. I managed to make it work.

      p12 was the missing bit.

      To create the p12 file, one way is:

      openssl pkcs12 -export -in client-2048.crt -inkey client-2048.key -out client-2048.p12

      Great work guys!

      Comment


        #18
        Helloo guys,

        I did everything you guys said, but I keep having problems with the method "send".
        Anyone have any other tips of what could be done?

        My "curl line" works. I've had issue with certificate, but putting the "Common Name" correct this ok (apparently).

        Now i am with Method 'Send' of object 'IWinHttpRequest' failed message =(

        Comment


          #19
          Originally posted by PeeOoo View Post
          Sorry for the delay, I thought I would get an email if anyone replied to my message. Will be more attentive in the future.

          Anyway here is a test routine I wrote in excel vba, just to get me started. I had to mess around to get it working but it ended up pretty simple. Sorry for the rubbish code, it's just a test, not what I would use in a proper application.


          Sub test1()

          Dim cookies As String
          Dim loggedIn As Boolean
          Dim oHTTP As Object: Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
          Dim ssoid As String
          Dim uri As String: uri = "https://identitysso.betfair.com/api/login?username=" + USERNAME + "&password=" + PASSWORD + "&login=true&redirectMethod=POST&product=home.betf air.int&url=https://www.betfair.com/"
          Dim x

          oHTTP.Open "POST", uri, False
          oHTTP.Send

          If oHTTP.Status >= 400 And oHTTP.Status <= 599 Then
          MsgBox ("Error Occurred : " & oHTTP.Status & " - " & oHTTP.statusText)
          GoTo finish
          End If

          MsgBox (oHTTP.ResponseText)
          MsgBox (oHTTP.getAllResponseHeaders())
          'MsgBox (oHTTP.getResponseHeader("Set-Cookie"))

          cookies = oHTTP.getResponseHeader("Set-Cookie")

          x = InStr(1, cookies, "ssoid=") + 6
          If x = 6 Then
          MsgBox ("Error logging in")
          GoTo finish
          End If
          ssoid = Mid(cookies, x, InStr(x, cookies + ";", ";") - x)

          MsgBox (ssoid)

          finish:

          End Sub
          Thanks for posting that. Not working for me though. My cookies string goes "wsid=...." rather than "ssoid=...". I've tried extracting the value and using that but then get errors telling me I'm using invalid session info. Any thoughts?

          Comment


            #20
            Do I need CertLogin or just Login for personal use??

            Hi,
            Has anyone managed to get CertLogin via Excel VBA going? I have been able to cobble together a function that works using:

            https://identitysso.betfair.com/api/login

            but not the CertLogin.

            My betting bot is for my own personal use and not shared with anyone. Isn't the https url "secure"? I'm confused as to whether I NEED to use the certificate or if my login and keepalive code is fine as it is.

            Any thoughts?

            Michael

            Comment


              #21
              There is no NEED to use a certificate if you are happy to use the interactive login.

              Comment


                #22
                Non-interactive api login after windows 10 update

                Hi, I was using this method to login to betfair api. Everything works fine, but after Windows 10 update (KB3140741) not working anymore. ResponseText = {"loginStatus":"CERT_AUTH_REQUIRED"} Anyone solved this?

                Windows 10 Build 10586.218, version 1511
                Microsoft Office 2016

                -----------------------------
                Dim oHTTP As Object: Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
                Dim uri As String: uri = "https://identitysso.betfair.com/api/certlogin"
                oHTTP.Open "POST", uri, False
                oHTTP.SetClientCertificate "Common Name"
                oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
                oHTTP.setRequestHeader "X-Application", App_key
                oHTTP.setRequestHeader "Accept", "application/json"
                oHTTP.send "username=" & UserName & "&password=" & Password & ""
                Last edited by TheOlis; 20-07-2016, 09:40 PM.

                Comment

                Working...
                X