Base class for interactive authentication credentials. This class should not be instantiated directly; use DeviceCodeCredential or AuthCodeCredential instead.
Public fields
use_refresh_tokenLogical indicating whether to use the login flow (acquire tokens via refresh token exchange).
interactiveLogical indicating whether this credential requires user interaction.
Methods
Inherited methods
Method new()
Shared initializer for interactive credentials
Usage
InteractiveCredential$new(
scope = NULL,
tenant_id = NULL,
client_id = NULL,
use_cache = "disk",
offline = TRUE,
interactive = TRUE,
use_refresh_token = TRUE,
flow_fun,
req_auth_fun,
oauth_endpoint,
name,
extra_flow_params = list()
)Arguments
scopeA character string specifying the OAuth2 scope.
tenant_idAzure AD tenant ID.
client_idApplication (client) ID.
use_cacheCache type:
"disk"or"memory".offlineWhether to request offline access (refresh tokens).
interactiveWhether this credential requires user interaction.
use_refresh_tokenWhether to use the login flow (acquire tokens via refresh token exchange). Set to
FALSEto use the access token flow directly.flow_funThe httr2 OAuth flow function (e.g. httr2::oauth_flow_device).
req_auth_funThe httr2 request auth function (e.g. httr2::req_oauth_device).
oauth_endpointThe OAuth endpoint name passed to the parent credential.
nameThe credential name passed to the parent credential.
extra_flow_paramsA named list of additional parameters merged into
private$.flow_paramsafterscopeandauth_url.
Method get_token()
Get an access token using the flow configured by the subclass.
Attempts token acquisition in three steps: (1) return a valid cached
token without any interaction; (2) silently refresh using an existing
refresh token; (3) fall back to the configured interactive flow.
When reauth = TRUE all three steps are skipped and the interactive
flow is used directly.
Arguments
scopeA character string specifying the OAuth2 scope. Defaults to
NULL, which uses the scope configured on the credential.reauthA logical value indicating whether to force reauthentication, bypassing the cache and silent refresh. Defaults to
FALSE.
Returns
An httr2::oauth_token() object containing the access token
Method req_auth()
Add OAuth authentication to an httr2 request using the flow configured by the subclass
Arguments
reqAn
httr2::request()object