req_oauth_password {httr2} | R Documentation |
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.
req_oauth_password(
req,
client,
username,
password = NULL,
cache_disk = FALSE,
scope = NULL,
token_params = list()
)
req |
A request. |
client |
An |
username |
User name. |
password |
Password. You avoid entering the password directly when
calling this function as it will be captured by |
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
|
A modified HTTP request.
client <- oauth_client("example", "https://example.com/get_token")
req <- request("https://example.com")
if (interactive()) {
req %>% req_oauth_password(client, "username")
}