Learn R Programming

googleAuthR - Google API R Client

gargle backend

As of version googleAuthR>=1.0.0 the OAuth2 and service JSON authentication is provided by gargle. Refer to that documentation for details.

The plan is to migrate as much functionality to gargle from googleAuthR, but backward compatibility will be maintained for all packages depending on googleAuthR in the meantime.

Once there is feature parity, client packages can then migrate totally to gargle. At time of writing some of the major features not in gargle yet are:

  • Shiny authentication flows
  • Paging
  • Caching
  • Batching

If you are not using the above then you can use gargle directly now. Otherwise you can still use googleAuthR that will use the features of gargle and wait for more features to be migrated.

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.

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:

remotes::install_github("MarkEdmondson1234/googleAuthR")

Copy Link

Version

Install

install.packages('googleAuthR')

Monthly Downloads

15,922

Version

2.0.2

License

MIT + file LICENSE

Maintainer

Last Published

May 22nd, 2024

Functions in googleAuthR (2.0.2)

gar_batch_walk

Walk data through batches
gar_deauth

Suspend authorization
gar_service_create

Work with service accounts via the API
gar_setup_edit_renviron

Setup wizard help - asking users to edit .Renviron
gar_service_provision

Provision a service account
gar_setup_env_check

Setup wizard help - check if environment argument is set
gar_setup_get_authenv

Setup wizard helper - add authentication file to .Renviron
gar_gce_auth_email

Get the service email via GCE metadata
gar_setup_menu

Setup wizard - introduction helper
gar_gce_auth_default

Authenticate via gcloud's application-default login
gar_discovery_api

Get meta data details for specified Google API
gar_cache_get_loc

Setup where to put cache
gar_token_info

Get current token summary
get_google_token

Retrieve Google token from environment and configs for httr
gar_discovery_apis_list

Get a list of Google API libraries
gar_has_token

Is there a token on hand?
gar_check_existing_token

Check a token vs options
gar_gce_auth

Authenticate on Google Compute Engine
googleAuthR

googleAuthR: Easy Authentication with Google OAuth2 APIs
gar_create_api_objects

Create the API objects from the Discovery API
gar_create_api_skeleton

Create an API library skeleton
googleSignIn

Google SignIn [Server Module]
gar_set_client

Setup the clientId, clientSecret and scopes
gar_shiny_auth_url

Make a Google Authorisation URL for Shiny
gar_setup_auth_key

Create a service account for googleCloudRunner
gar_setup_menu_do

Setup wizard help - the functions that will execute on different menu options
gar_setup_auth_check

Check service key works via environment argument
gar_setup_clientid

Check for a client JSON
gar_shiny_auth

Create Authentication within Shiny's server.R
gar_scope_config

Create or add scopes to configuration
retryRequest

ReTry API requests for certain errors using exponential backoff.
googleSignInUI

Google SignIn [UI Module]
should_skip_token_checks

Determines whether token presence and validity checks should be skipped.
skip_if_no_env_auth

Skip test if not authenticated
token_exists

Check if authorization currently in force
gar_shiny_login_ui

A login page for Shiny
silent_auth

Silent auth
gar_shiny_ui

Create a Google login before your Shiny UI launches
gar_token

Produce configured token
gar_attach_auto_auth

Auto Authentication function for use within .onAttach
checkGoogleAPIError

Get Google API errors
gar_auth_service

JSON service account authentication
gar_auto_auth

Perform auto authentication
gar_auth

Authorize googleAuthR
gar_auth_configure

Edit and view auth configuration
gar_api_generator

googleAuthR data fetch function generator
gar_api_page

Takes a generated API function and lets you page through results
gar_batch

Turn a list of gar_fetch_functions into batch functions
gar_create_package

Create a Google API package
gar_debug_parsing

Read the diagnostic object returned on API parse errors.
checkTokenAPI

Check API data token
doHttrRequest

Get URL content based on if its Shiny or local