Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gar_attach_auto_auth

Auto Authentication function for use within .onAttach


Description

To be placed within .onAttach to auto load an authentication file from an environment variable.

Usage

gar_attach_auto_auth(required_scopes, environment_var = "GAR_AUTH_FILE")

Arguments

required_scopes

A character vector of minimum required scopes for this API library

environment_var

The name of the environment variable where the file path to the authentication file is kept

This function works with gar_auto_auth. It is intended to be placed within the .onAttach hook so that it loads when you load your library.

For auto-authentication to work, the environment variable needs to hold a file path to an existing auth file such as created via gar_auth or a JSON file file download from the Google API console.

Value

Invisible, used for its side effects of calling auto-authentication.

See Also

Other authentication functions: gar_auth_service(), gar_auth(), gar_auto_auth(), gar_gce_auth(), get_google_token(), token_exists()

Examples

## Not run: 

.onAttach <- function(libname, pkgname){

  googleAuthR::gar_attach_auto_auth("https://www.googleapis.com/auth/urlshortener", "US_AUTH_FILE")

}

## will only work if you have US_AUTH_FILE environment variable pointing to an auth file location
## .Renviron example
US_AUTH_FILE="/home/mark/auth/urlshortnerauth.json"


## End(Not run)

googleAuthR

Authenticate and Create Google APIs

v1.4.0
MIT + file LICENSE
Authors
Mark Edmondson [aut, cre] (<https://orcid.org/0000-0002-8434-3881>), Jennifer Bryan [ctb], Johann deBoer [ctb], Neal Richardson [ctb], David Kulp [ctb], Joe Cheng [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.