View source: R/oauth-flow-password.R
req_oauth_password | R Documentation |
This function implements the OAuth resource owner password flow, as defined by Section 4.3 of RFC 6749. It allows the user to supply their password once, exchanging it for an access token that can be cached locally.
Learn more about the overall OAuth authentication flow in https://httr2.r-lib.org/articles/oauth.html
req_oauth_password(
req,
client,
username,
password = NULL,
scope = NULL,
token_params = list(),
cache_disk = FALSE,
cache_key = username
)
oauth_flow_password(
client,
username,
password = NULL,
scope = NULL,
token_params = list()
)
req |
A httr2 request object. |
client |
An |
username |
User name. |
password |
Password. You should avoid entering the password directly
when calling this function as it will be captured by |
scope |
Scopes to be requested from the resource owner. |
token_params |
List containing additional parameters passed to the
|
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. Learn more in https://httr2.r-lib.org/articles/oauth.html. |
cache_key |
If you want to cache multiple tokens per app, use this key to disambiguate them. |
req_oauth_password()
returns a modified HTTP request that will
use OAuth; oauth_flow_password()
returns an oauth_token.
Other OAuth flows:
req_oauth_auth_code()
,
req_oauth_bearer_jwt()
,
req_oauth_client_credentials()
,
req_oauth_refresh()
,
req_oauth_token_exchange()
req_auth <- function(req) {
req_oauth_password(req,
client = oauth_client("example", "https://example.com/get_token"),
username = "username"
)
}
if (interactive()) {
request("https://example.com") |>
req_auth()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.