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 googleAuthR.scopes.selected.

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"))

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:
  4. options("googleAuthR.client_id" = "YOUR_CLIENT_ID")
  5. options("googleAuthR.client_secret" = "YOUR_CLIENT_SECRET")

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:
  6. options("googleAuthR.webapp.client_id" = "YOUR_CLIENT_ID")
  7. options("googleAuthR.webapp.client_secret" = "YOUR_CLIENT_SECRET")
  8. Run the app locally specifying the port number you used e.g. shiny::runApp(port=1221)
  9. 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"))


yinscapital/googleAuthR-reference documentation built on May 3, 2019, 4:31 p.m.