Auto-build libraries for Google APIs with OAuth2 for both local and Shiny app use.
This guide is also available at the googleAuthR website
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 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
googleAuthR is available on CRAN:
If you want to use the development version on Github, install via:
This takes care of getting the authentication token, storing it and refreshing.
Use it before any call to a Google library.
googleAuthR has a default project setup with APIs activated for several APIs, but it is recommended you use your own Client IDs as the login screen will be big and scary for users with so many APIs to approve.
It is preferred to configure your functions to only use the scopes they need. Scopes you need will be specified in the Google API documentation. Set scopes via the option
The below example sets scopes for Search Console, Google Analytics and Tag Manager:
options("googleAuthR.scopes.selected" = c("https://www.googleapis.com/auth/webmasters", "https://www.googleapis.com/auth/analytics", "https://www.googleapis.com/auth/tagmanager.readonly"))
googleAuthRhas been loaded:
options("googleAuthR.client_id" = "YOUR_CLIENT_ID")
options("googleAuthR.client_secret" = "YOUR_CLIENT_SECRET")
options("googleAuthR.webapp.client_id" = "YOUR_CLIENT_ID")
options("googleAuthR.webapp.client_secret" = "YOUR_CLIENT_SECRET")