Skip to content

Instantly share code, notes, and snippets.

@sergio1990
Last active December 22, 2016 17:24
Show Gist options
  • Save sergio1990/9408526 to your computer and use it in GitHub Desktop.
Save sergio1990/9408526 to your computer and use it in GitHub Desktop.
Request ssoid for accesing API-NG betfair.com
require "net/https"
require "uri"
crt = File.read("client-2048.crt")
key = File.read("client-2048.key")
app_key = "YOUR_APP_KEY"
username = "YOUR_USERNAME"
password = "YOUR_PASSWORD"
uri = URI.parse("https://identitysso.betfair.com/api/certlogin")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(crt)
http.key = OpenSSL::PKey::RSA.new(key)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/x-www-form-urlencoded"
request["X-Application"] = app_key
request.set_form_data({"username" => username, "password" => password})
response = http.request request
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment