Google API Setup

Mark Edmondson

2019-09-08

Install

googleAuthR is available on CRAN

install.packages("googleAuthR")

If you want to use the development version on Github, install via:

remotes::install_github("MarkEdmondson1234/googleAuthR")

Set up steps

  1. Create a Google Cloud Project. You will also need billing attached if the API needs it.
  2. Set up your project in the Google API Console to use the Google API you want:

For local use

  1. Click ‘Create a new Client ID’, and choose “Installed Application”.
  2. Download the client JSON file
  3. Set the GAR_CLIENT_JSON environment argument (via .Renviron or otherwise) to the full path file location of the JSON file (see gar_set_client() for other options)

For Shiny use

  1. Click ‘Create a new Client ID’, and choose “Web Application”.
  2. Download the web client JSON file
  3. Add the URL of where your Shiny app will run to the crendetials, with no port number. e.g. https://mark.shinyapps.io/searchConsoleRDemo/
  4. And/Or also put in localhost or 127.0.0.1 with a port number for local testing. Remember the port number you use as you will need it later to launch the app e.g. http://127.0.0.1:1221
  5. Set the GAR_CLIENT_WEB_JSON environment argument (via .Renviron or otherwise) to the full path file location of the JSON file (see gar_set_client() for other options)
  6. Run the app locally specifying the port number you used e.g. shiny::runApp(port=1221)
  7. Or deploy to your Shiny Server that deploys to web port (80 or 443).

Activate API

  1. In the Google Cloud Platform Click on “APIs” menu to the left
  2. Select and activate the API you want to use.
  3. Go to the documentation and find the API scope URL
  4. Set option in your R script for the scope via gar_set_client()