Authorize googledrive to view and manage your Drive files. By default, you
are directed to a web browser, asked to sign in to your Google account,
and to grant googledrive (the tidyverse, actually) permission to operate on
your behalf with 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.
drive_auth(oauth_token = NULL, service_token = NULL, reset = FALSE, cache = getOption("httr_oauth_cache"), use_oob = getOption("httr_oob_default"), verbose = TRUE)
| oauth_token | Optional; path to an |
|---|---|
| service_token | Optional; a JSON string, URL, or path, giving or pointing to the service token file. |
| reset | Logical, defaults to |
| cache | A logical value or a string. |
| use_oob | if FALSE, use a local webserver for the OAuth dance.
Otherwise, provide a URL to the user and prompt for a validation
code. Defaults to the of the |
| verbose | Logical, indicating whether to print informative messages
(default |
Most users, most of the time, do not need to call drive_auth() explicitly
-- it is 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 adoption of a new token, via reset = TRUE
retrieve current token, e.g., for storage to an .rds file
put a pre-existing OAuth or service account token into force
prevent the caching of new, interactively-obtained credentials in
.httr-oauth
For even deeper control over auth, use drive_auth_config() to use your own
OAuth app or API key. drive_auth_config() also allows you to
deactivate auth, sending only an API key in requests, which works if you
only need to access public data.
More detail is available from Using OAuth 2.0 for Installed Applications
Other auth functions: drive_auth_config,
drive_deauth
# NOT RUN { ## load/refresh existing credentials, if available ## otherwise, go to browser for authentication and authorization drive_auth() ## force a new oauth token to be obtained drive_auth(reset = TRUE) ## store token in an object and then to file ttt <- drive_auth() saveRDS(ttt, "ttt.rds") ## load a pre-existing token drive_auth("ttt.rds") # from .rds file ## use a service account token drive_auth(service_token = "foofy-83ee9e7c9c48.json") # }