Skip to content

Commit

Permalink
Updates to loginBF() to support self signed SSL certificates.
Browse files Browse the repository at this point in the history
  • Loading branch information
phillc73 committed Dec 21, 2014
1 parent d0f6690 commit 307ac2a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: abettor
Title: R bindings to Betfair API-NG
Version: 0.1.1
Date: 2014-12-15
Version: 0.1.2
Date: 2014-12-21
Authors@R: as.person(c("Phill Clarke <phill@starkingdom.co.uk> [aut, cre]"))
Description: An R package for connecting to the online betting exchange,
Betfair, via their API-NG product using JSON-RPC. The package user can
Expand Down
19 changes: 17 additions & 2 deletions R/loginBF.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
#' defined. See Examples.
#' @param applicationKey Character string containing Betfair application key and
#' must be defined. See Examples.
#' @param sslVerify Boolean. This argument defaults to TRUE and is optional. In
#' some cases, where users have a self signed SSL Certificate, for example
#' they may be behind a proxy server, Betfair will fail login with "SSL
#' certificate problem: self signed certificate in certificate chain". If this
#' error occurs you may set sslVerify to FALSE. This does open a small
#' security risk of a man-in-the-middle intercepting your login credentials.
#' See Examples.
#' @return Response from Betfair will be stored in {loginReturn}. Examples of
#' login responses for the JSON API interactive endpoint can be found here:
#'
Expand All @@ -44,16 +51,24 @@
#' password = "YourBetfairPassword",
#' applicationKey = "YourBetfairAppKey"
#' )
#'
#' # Login with self signed SSL Certificate
#' loginBF(username = "YourBetfairUsername",
#' password = "YourBetfairPassword",
#' applicationKey = "YourBetfairAppKey",
#' sslVerify = FALSE
#' )
#'
#' }
#'

loginBF <- function(username, password, applicationKey){
loginBF <- function(username, password, applicationKey, sslVerify = TRUE){

credentials <- paste("username=",username,"&password=",password,sep="")

headersLogin <- list('Accept' = 'application/json', 'X-Application' = applicationKey)

loginReturn <- RCurl::postForm("https://identitysso.betfair.com/api/login", .opts=list(postfields=credentials, httpheader=headersLogin))
loginReturn <- RCurl::postForm("https://identitysso.betfair.com/api/login", .opts=list(postfields=credentials, httpheader=headersLogin, ssl.verifypeer = sslVerify))

authenticationKey <- jsonlite::fromJSON(loginReturn)

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ Each function contains documented descriptions for their use and all supported a

This package is under active development.

Current Version: 0.1.1
Current Version: 0.1.2

See [current release notes](https://github.com/phillc73/abettor/releases) for more details.

### Issues

Expand Down
18 changes: 17 additions & 1 deletion man/loginBF.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{loginBF}
\title{Login to Betfair, interactive end point.}
\usage{
loginBF(username, password, applicationKey)
loginBF(username, password, applicationKey, sslVerify = TRUE)
}
\arguments{
\item{username}{Character string containing Betfair username and must be
Expand All @@ -15,6 +15,14 @@ defined. See Examples.}

\item{applicationKey}{Character string containing Betfair application key and
must be defined. See Examples.}

\item{sslVerify}{Boolean. This argument defaults to TRUE and is optional. In
some cases, where users have a self signed SSL Certificate, for example
they may be behind a proxy server, Betfair will fail login with "SSL
certificate problem: self signed certificate in certificate chain". If this
error occurs you may set sslVerify to FALSE. This does open a small
security risk of a man-in-the-middle intercepting your login credentials.
See Examples.}
}
\value{
Response from Betfair will be stored in {loginReturn}. Examples of
Expand Down Expand Up @@ -59,6 +67,14 @@ loginBF(username = "YourBetfairUsername",
password = "YourBetfairPassword",
applicationKey = "YourBetfairAppKey"
)
# Login with self signed SSL Certificate
loginBF(username = "YourBetfairUsername",
password = "YourBetfairPassword",
applicationKey = "YourBetfairAppKey",
sslVerify = FALSE
)
}
}

0 comments on commit 307ac2a

Please sign in to comment.