Learn R Programming

⚠️There's a newer version (2.0.2) of this package.Take me there.

googleAuthR - Google API R Client

Overview

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.

Summary

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.

R Google API libraries using googleAuthR

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.

Example Shiny app

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

Thanks to

Install

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:

devtools::install_github("MarkEdmondson1234/googleAuthR")

Copy Link

Version

Install

install.packages('googleAuthR')

Monthly Downloads

20,279

Version

0.6.0

License

MIT + file LICENSE

Maintainer

Mark Edmondson

Last Published

October 20th, 2017

Functions in googleAuthR (0.6.0)

doBatchRequest

Batch Requests
doHttrRequest

Get URL content based on if its Shiny or local
checkTokenAPI

Check API data token
createCode

Creates a random character code
gar_auto_auth

Perform auto authentication
gar_batch

Turn a list of gar_fetch_functions into batch functions
gar_shiny_getAuthUrl

Returns the Google authentication URL
gar_shiny_getToken

Returns the authentication Token.
authReturnCode

Returns the authentication parameter "code" in redirected URLs
checkGoogleAPIError

Get Google API errors
gar_batch_walk

Walk data through batches
gar_cache_get_loc

Setup where to put cache
gar_discovery_api

Get meta data details for specified Google API
gar_discovery_apis_list

Get a list of Google API libraries
parseBatchResponse

Parse batch request
reactiveAccessToken

Create a reactive Google OAuth2 token
gar_auth

Authorize googleAuthR
gar_auth_js

Shiny JavaScript Google Authorisation [Server Module]
gar_create_api_skeleton

Create an API library skeleton
gar_create_package

Create a Google API package
loginOutput

Login/logout Shiny output
makeBatchRequest

Make the batch request inner content
renderLogin

Render a Google API Authentication Login/logout button
retryRequest

ReTry API requests for certain errors using exponential backoff.
revokeEventObserver

Listens for a user revoking authentication
skip_if_no_env_auth

Skip test if not authenticated
Authentication

R6 environment to store authentication credentials
applyDataParseFunction

Apply parsing function if a good response
gar_auth_jsUI

Shiny JavaScript Google Authorisation [UI Module]
gar_api_generator

googleAuthR data fetch function generator
gar_attach_auto_auth

Auto Authentication function for use within .onAttach
gar_check_existing_token

Check a token vs options
gar_create_api_objects

Create the API objects from the Discovery API
gar_shiny_getUrl

Get the Shiny Apps URL.
gar_auth_service

JSON service account authentication
gar_gce_auth

Authenticate on Google Compute Engine
gar_gce_auth_email

Get the service email via GCE metadata
get_google_token

Retrieve Google token from environment and configs for httr
googleAuth

Server side google auth (Shiny Module)
gar_token_info

Get current token summary
googleAuthR

googleAuthR: Easy Authentication with Google OAuth2 APIs
googleAuthUI

A Login button (Shiny Module)
token_exists

Check if authorization currently in force
with_shiny

Turn a googleAuthR data fetch function into a Shiny compatible one