Google API Setup

Mark Edmondson

2017-11-14

Install

googleAuthR is available on CRAN

install.packages("googleAuthR")

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

devtools::install_github("MarkEdmondson1234/googleAuthR")

Set up steps

  1. 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. Note your Client ID and secret.
  3. Modify these options after googleAuthR has been loaded:

For Shiny use

  1. Click ‘Create a new Client ID’, and choose “Web Application”.
  2. Note your Client ID and secret.
  3. Add the URL of where your Shiny app will run, 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. In your Shiny script modify these options:
  1. Run the app locally specifying the port number you used e.g. shiny::runApp(port=1221)
  2. Or deploy to your Shiny Server that deploys to web port (80 or 443).

Activate API

  1. Click on “APIs”
  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 e.g.
options("googleAuthR.scopes.selected" = 
      c("https://www.googleapis.com/auth/urlshortener"))