credentials_user_oauth2 {gargle} | R Documentation |
Consults the token cache for a suitable OAuth token and, if unsuccessful, gets a token via the browser flow. A cached token is suitable if it's compatible with the user's request in this sense:
OAuth client must be same.
Scopes must be same.
Email, if provided, must be same. If specified email is a glob pattern
like "*@example.com"
, email matching is done at the domain level.
gargle is very conservative about using OAuth tokens discovered in the user's
cache and will generally seek interactive confirmation. Therefore, in a
non-interactive setting, it's important to explicitly specify the "email"
of the target account or to explicitly authorize automatic discovery. See
gargle2.0_token()
, which this function wraps, for more. Non-interactive use
also suggests it might be time to use a service account token or workload identity federation.
credentials_user_oauth2( scopes = NULL, app = gargle_client(), package = "gargle", ... )
scopes |
A character vector of scopes to request. Pick from those listed at https://developers.google.com/identity/protocols/oauth2/scopes. For certain token flows, the
|
app |
A Google OAuth client, preferably constructed via
|
package |
Name of the package requesting a token. Used in messages. |
... |
Arguments passed on to
|
A Gargle2.0 token.
Other credential functions:
credentials_app_default()
,
credentials_byo_oauth2()
,
credentials_external_account()
,
credentials_gce()
,
credentials_service_account()
,
token_fetch()
## Not run: # Drive scope, built-in gargle demo client scopes <- "https://www.googleapis.com/auth/drive" credentials_user_oauth2(scopes, app = gargle_client()) # bring your own client client <- gargle_oauth_client_from_json( path = "/path/to/the/JSON/you/downloaded/from/gcp/console.json", name = "my-nifty-oauth-client" ) credentials_user_oauth2(scopes, client) ## End(Not run)