Create R functions that interact with OAuth2 Google APIs < https://developers.google.com/apis-explorer/> easily, with auto-refresh and Shiny compatibility.
This library allows you to authenticate easily via local use in an OAuth2 flow; within a Shiny app; or via service accounts.
The main two functions are gar_auth()
and gar_api_generator()
.
gar_auth
This takes care of getting the authentication token, storing it and refreshing. Use it before any call to a Google library.
gar_api_generator
This creates functions for you to use to interact with Google APIs. Use it within your own function definitions, to query the Google API you want.
Auto-build libraries for Google APIs with OAuth2 for both local and Shiny app use.
Get more details at the googleAuthR website
The googleAuthRverse
Slack team has been setup for support for using googleAuthR
and the libraries it helps create. Sign up via this Google form to get access.
Here is a list of available Google APIs to make with this library.
The below libraries are all cross-compatible as they use googleAuthR
for authentication backend e.g. can use just one OAuth2 login flow and can be used in multi-user Shiny apps.
Feel free to add your own via email or a pull request if you have used googleAuthR to build something cool.
googleAuthR
now has an R package generator which makes R package skeletons you can use to build your own Google API R package upon. Browse through the 154 options at this Github repository.
An example shiny app with Google authentication is deployed to shinyapps.io here. It uses the example app that is available in system.file("shiny", package="googleAuthR")
googleAuthR is available on CRAN
install.packages("googleAuthR")
Check out News to see the features of the development version.
If you want to use the development version on Github, install via:
remotes::install_github("MarkEdmondson1234/googleAuthR")
https://www.googleapis.com/batch
batch endpoint fully as per https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.htmlgar_api_page()
to help page through APIs (#121)url_override
argument to generated Google API functions to help with (#121)googleSignIn
gar_shiny_auth()
gar_set_client
(#107).httr-oauth
file (#84)gar_batch_walk()
with some examples (#175)gar_set_client
to load client id/secret from JSON (Idea via @jennybc / @jimhester at gargle
/gmailr
)gar_auth(token = "blah")
that doesn't exist, will create new token there instead of an erroroptions()
or by setting up environment arguments (#74):
GAR_CLIENTID
GAR_CLIENT_SECRET
GAR_WEB_CLIENTID
GAR_WEB_CLIENT_SECRET
GAR_SCOPE
gar_gce_auth_email
httr
s RETRY
function for retries that handles handles better (#67)googleAuthR.batch_endpoint
option for specific library batches.gar_check_existing_token()
to improve user feedback on why a reauthentication occurshttp2 framing layer error
that sometimes happens in misconfigured http2 servers (#87)3.3.0
to support Shiny function bugs.gar_auto_auth
where it expects a file.path not a token objectgar_gce_auth()
(#52).httr-oauth
token has different scopes to the ones specified at time of authentication (#53)option(googleAuthR.verbose = 0)
then a request with a body will write to a file request_debug.rds
in working directorygar_auth("file-location.rds")
will only load the first element [[1]]
if that token is a list of Token2.0
class objectsgar_token_info()
which will report on current authentication. Available at options(googleAuthR.verbose = 2)
gar_auth_service
to see if you have downloaded right JSON filegar_discovery_apis_list
and gar_discovery_api
gar_create_package
that takes gar_discovery_api
JSON and creates R packagegar_auto_auth
and gar_attach_auto_auth
for auto-authentication upon a package loadgar_auth()
gar_auth
now raises errors not NULL for passing incorrect token file locations of tokensgar_auth
respects renamed .httr-oauth
tokens now via getOption("googleAuthR.httr_oauth_cache")
https://github.com/MarkEdmondson1234/autoGoogleAPI
option(googleAuthR.rawResponse)
- skip API checks on response - should now work?googleAuthR
option(googleAuthR.rawResponse)
- skip API checks on response./inst/shiny/shiny-example.R
googleAuthR:::gar_gadget()
getOption("googleAuthR.jsonlite.simplifyVector")
googleAuthR.verbose
to control feedback. 0 = everything, 1 = debug, 2=normal, 3=importantgar_auth_service
to param for more flexibilitycustomConfig
in gar_api_generator
gar_shiny_getUrl
and the authentication type (online/offline) in renderLogin
renderLogin
: logout now has option revoke
to revoke authentication tokengoogleAuthR.jsonlite.simplifyVector
for content parsing for compatibility for some APIs?gar_batch
and ?gar_batch_walk
for details.!is.null(access_token())
to detect login statewith_shiny
environment lookup to within generated function