path_args: A named list with name=folder in request URI, value=the function variable.
pars_args: A named list with name=parameter in request URI, value=the function variable.
data_parse_function: A function that takes a request response, parses it and returns the data you need.
customConfig: list of httr options such as use_proxy
or add_headers that will be added to the request.
simplifyVector: Passed to fromJSON for response parsing
checkTrailingSlash: Default TRUE will append a trailing slash to baseURI if missing
Returns
A function that can fetch the Google API data you specify
Details
path_args and pars_args add default values to the baseURI. NULL entries are removed. Use "" if you want an empty argument.
You don't need to supply access_token for OAuth2 requests in pars_args, this is dealt with in gar_auth()
Add custom configurations to the request in this syntax: customConfig = list(httr::add_headers("From" = "mark@example.com")
Examples
## Not run:library(googleAuthR)## change the native googleAuthR scopes to the one needed.options("googleAuthR.scopes.selected"="email")get_email <-function(){ f <- gar_api_generator("https://openidconnect.googleapis.com/v1/userinfo","POST", data_parse_function =function(x) x$email, checkTrailingSlash =FALSE) f()}To use the above functions:library(googleAuthR)# go through authentication flowgar_auth()s <- get_email()s
## End(Not run)