OAuth authentication with username and password
Source:R/oauth-flow-password.R
req_oauth_password.Rd
This uses oauth_flow_password()
to generate an access token, which is
then used to authentication the request with req_auth_bearer_token()
.
The token, not the password is automatically cached (either in memory
or on disk); the password is used once to get the token and is then
discarded.
Usage
req_oauth_password(
req,
client,
username,
password = NULL,
cache_disk = FALSE,
scope = NULL,
token_params = list()
)
Arguments
- req
A request.
- client
An
oauth_client()
.- username
User name.
- password
Password. You avoid entering the password directly when calling this function as it will be captured by
.Rhistory
. Instead, leave it unset and the default behaviour will prompt you for it interactively.- cache_disk
Should the access token be cached on disk? This reduces the number of times that you need to re-authenticate at the cost of storing access credentials on disk. Cached tokens are encrypted and automatically deleted 30 days after creation.
- scope
Scopes to be requested from the resource owner.
- token_params
List containing additional parameters passed to the
token_url
.
Value
A modified HTTP request.
Examples
client <- oauth_client("example", "https://example.com/get_token")
req <- request("https://example.com")
if (interactive()) {
req %>% req_oauth_password(client, "username")
}