Description Usage Arguments Details Value See Also Examples
Authorize googlesheets
to view and manage your files. You will be
directed to a web browser, asked to sign in to your Google account, and to
grant googlesheets
permission to operate on your behalf with Google
Sheets and Google Drive. By default, these user credentials are cached in a
file named .httr-oauth
in the current working directory, from where
they can be automatically refreshed, as necessary.
1 2 3 4 |
token |
optional; an actual token object or the path to a valid token
stored as an |
new_user |
logical, defaults to |
key, secret |
the "Client ID" and "Client secret" for the application;
defaults to the ID and secret built into the |
cache |
logical indicating if |
verbose |
logical; do you want informative messages? |
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:
Set to option googlesheets.client_id
, which defaults to
a client ID that ships with the package
Set to option googlesheets.client_secret
, which
defaults to a client secret that ships with the package
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:
1 2 3 |
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.
an OAuth token object, specifically a
Token2.0
, invisibly
Other auth functions: gd_user
,
gs_deauth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
## load/refresh existing credentials, if available
## otherwise, go to browser for authentication and authorization
gs_auth()
## force a new token to be obtained
gs_auth(new_user = TRUE)
## store token in an object and then to file
ttt <- gs_auth()
saveRDS(ttt, "ttt.rds")
## load a pre-existing token
gs_auth(token = ttt) # from an object
gs_auth(token = "ttt.rds") # from .rds file
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.