From 89471b72fe4d995fe6065c5cea6c78e5ec3469f5 Mon Sep 17 00:00:00 2001 From: cschwarz007 Date: Sun, 13 Oct 2024 21:54:19 +0200 Subject: [PATCH 1/3] Update get_session_key.R --- R/get_session_key.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/get_session_key.R b/R/get_session_key.R index b188455..8c8d2c7 100644 --- a/R/get_session_key.R +++ b/R/get_session_key.R @@ -3,6 +3,7 @@ #' This function logs into the LimeSurvey API and provides an access session key. #' @param username LimeSurvey username. Defaults to value set in \code{options()}. #' @param password LimeSurvey password Defaults to value set in \code{options()}. +#' @param plugn LimeSurvey Auth Plugin Defaults to value set in \code{options() - if no value set uses Authdb}. #' @return API token #' @import httr #' @export @@ -11,11 +12,13 @@ #' } get_session_key <- function(username = getOption('lime_username'), - password = getOption('lime_password')) { + password = getOption('lime_password'), + plugin = getOption('lime_auth',default='Authdb')) { body.json = list(method = "get_session_key", id = " ", params = list(username = username, - password = password)) + password = password, + plugin = plugin)) # Need to use jsonlite::toJSON because single elements are boxed in httr, which # is goofy. toJSON can turn off the boxing automatically, though it's not From 5ca513d673bd28bbf991dfc79db62729c57f8932 Mon Sep 17 00:00:00 2001 From: cschwarz007 Date: Sun, 13 Oct 2024 21:57:00 +0200 Subject: [PATCH 2/3] Update get_session_key.R --- R/get_session_key.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_session_key.R b/R/get_session_key.R index 8c8d2c7..b6df958 100644 --- a/R/get_session_key.R +++ b/R/get_session_key.R @@ -3,7 +3,7 @@ #' This function logs into the LimeSurvey API and provides an access session key. #' @param username LimeSurvey username. Defaults to value set in \code{options()}. #' @param password LimeSurvey password Defaults to value set in \code{options()}. -#' @param plugn LimeSurvey Auth Plugin Defaults to value set in \code{options() - if no value set uses Authdb}. +#' @param auth LimeSurvey Auth Plugin Defaults to value set in \code{options() - if no value set uses Authdb}. #' @return API token #' @import httr #' @export From 71edf414727394f13dc6dda7e727f24db3157f3a Mon Sep 17 00:00:00 2001 From: cschwarz007 Date: Sun, 13 Oct 2024 21:58:52 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7485251..39bb897 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ Load your API details and user credentials into R using `options()`: options(lime_api = 'http://example.com/limesurvey/admin/remotecontrol') options(lime_username = 'put_username_here') options(lime_password = 'put_password_here') +options(lime_auth = 'AuthLDAP') ``` +lime_auth is an optional parameter. If you do not set it, it will default to 'Authdb', which is the standard way of authentication in LimeSurvey. But if the LimeSurvey installation is set to use LDAP for authentication (as in many Universities), set it to 'AuthLDAP'. Before calling the API, you need to generate an access token with `get_session_key()` (examples of how to do this are shown below). Many services provide tokens that last indefinitely, but by default LimeSurvey's will only last for two hours. (this can be modified by editing `limesurvey/application/config/config-default.php` and changing `$config['iSessionExpirationTime'] = 7200;` to something else). @@ -32,6 +34,7 @@ library(limer) options(lime_api = 'http://example.com/limesurvey/admin/remotecontrol') options(lime_username = 'put_username_here') options(lime_password = 'put_password_here') +options(lime_auth = 'AuthLDAP') # Do stuff with LimeSurvey API get_session_key() # Log in