Gargle2.0 is based on the Token2.0 class provided in
httr. The preferred way to create a Gargle2.0 token is through the
constructor function gargle2.0_token(). Key differences with Token2.0:
The key for a cached Token2.0 comes from hashing the endpoint, app, and
scopes. For the Gargle2.0 subclass, the identifier or key is expanded to
include the email address associated with the token. This makes it easier to
work with Google APIs with multiple identities.
Gargle2.0 tokens are cached, by default, below
"~/.R/gargle/gargle-oauth", i.e. at the user level. In contrast, the
default location for Token2.0 is ./.httr-oauth, i.e. in current working
directory. Gargle2.0 behaviour makes it easier to reuse tokens across
projects and makes it less likely that tokens are accidentally synced to a
remote location like GitHub or DropBox.
Each Gargle2.0 token is cached in its own file. The token cache is a
directory of such files. In contrast, Token2.0 tokens are cached as
components of a list, which is typically serialized to ./.httr-oauth.
httr::Token -> httr::Token2.0 -> Gargle2.0
emailEmail associated with the token.
packageName of the package requesting a token. Used in messages.
new()Create a Gargle2.0 token
Gargle2.0$new( email = gargle_oauth_email(), app = gargle_app(), package = "gargle", credentials = NULL, params = list(), cache_path = gargle_oauth_cache() )
emailOptional email address. See gargle2.0_token() for full details.
appAn OAuth consumer application.
packageName of the package requesting a token. Used in messages.
credentialsExists largely for testing purposes.
paramsA list of parameters for httr::init_oauth2.0(). Some we
actively use in gargle: scope, use_oob. Most we do not:
user_params, type, as_header, use_basic_auth, config_init,
client_credentials.
cache_pathSpecifies the OAuth token cache. Read more in
gargle::gargle_oauth_cache().
A Gargle2.0 token.
print()Print a Gargle2.0 token
Gargle2.0$print(...)
...Not used.
hash()Generate the email-augmented hash of a Gargle2.0 token
Gargle2.0$hash()
cache()Put a Gargle2.0 token into the cache
Gargle2.0$cache()
load_from_cache()(Attempt to) get a Gargle2.0 token from the cache
Gargle2.0$load_from_cache()
refresh()(Attempt to) refresh a Gargle2.0 token
Gargle2.0$refresh()
init_credentials()Initiate a new Gargle2.0 token
Gargle2.0$init_credentials()
clone()The objects of this class are cloneable with this method.
Gargle2.0$clone(deep = FALSE)
deepWhether to make a deep clone.