gm_auth_configure {gmailr} | R Documentation |
These functions give more control over and visibility into the auth
configuration than gm_auth()
does. gm_auth_configure()
lets the user specify their own:
OAuth app, which is used when obtaining a user token.
See the vignette
How to get your own API credentials
for more.
If the user does not configure these settings, internal defaults
are used.
gm_oauth_app()
retrieves the currently configured OAuth app.
gm_auth_configure(key = "", secret = "", path = Sys.getenv("GMAILR_APP"), appname = "gmailr", ..., app = httr::oauth_app(appname, key, secret, ...)) gm_oauth_app()
key |
consumer key, also sometimes called the client ID |
secret |
consumer secret, also sometimes called the client secret. |
path |
JSON downloaded from Google Cloud Platform Console, containing a
client id (aka key) and secret, in one of the forms supported for the |
appname |
name of the application. This is not used for OAuth, but is used to make it easier to identify different applications. |
... |
Additional arguments passed to |
app |
OAuth app, in the sense of |
gm_auth_configure()
: An object of R6 class
gargle::AuthState, invisibly.
gm_oauth_app()
: the current user-configured
httr::oauth_app()
.
Other auth functions: gm_deauth
,
gm_scopes
## Not run: # see the current user-configured OAuth app (probaby `NULL`) gm_oauth_app() if (require(httr)) { # store current state, so we can restore original_app <- gm_oauth_app() # bring your own app via client id (aka key) and secret google_app <- httr::oauth_app( "my-awesome-google-api-wrapping-package", key = "123456789.apps.googleusercontent.com", secret = "abcdefghijklmnopqrstuvwxyz" ) gm_auth_configure(app = google_app) # confirm current app gm_oauth_app() # restore original state gm_auth_configure(app = original_app) gm_oauth_app() } # bring your own app via JSON downloaded from Google Developers Console gm_auth_configure( path = "/path/to/the/JSON/you/downloaded/from/google/dev/console.json" ) ## End(Not run)