Most users, most of the time, do not need to call this function
explicitly -- it will be triggered by the first action that
requires authorization. Even when called, the default arguments will often
suffice. However, when necessary, this function allows the user to
force the creation of a new token
retrieve current token as an object, for possible storage to an
.rds file
read the token from an object or from an .rds file
provide your own app key and secret -- this requires setting up a new
project in
Google Developers Console
prevent caching of credentials in .httr-oauth
In a direct call to gs_auth, the user can provide the token, app key
and secret explicitly and can dictate whether interactively-obtained
credentials will be cached in .httr_oauth. If unspecified, these
arguments are controlled via options, which, if undefined at the time
googlesheets is loaded, are defined like so:
- key
Set to option googlesheets.client_id, which defaults to
a client ID that ships with the package
- secret
Set to option googlesheets.client_secret, which
defaults to a client secret that ships with the package
- cache
Set to option googlesheets.httr_oauth_cache, which
defaults to TRUE
To override these defaults in persistent way, predefine one or more of
them with lines like this in a .Rprofile file:
options(googlesheets.client_id = "FOO",
googlesheets.client_secret = "BAR",
googlesheets.httr_oauth_cache = FALSE)
See Startup for possible locations for this file and the
implications thereof.
More detail is available from
Using
OAuth 2.0 for Installed Applications. See gs_webapp_auth_url
and gs_webapp_get_token for functions that execute the "web
server application" flow.