View source: R/oauth-flow-device.R
req_oauth_device | R Documentation |
Authenticate using the OAuth device flow, as defined by RFC 8628. It's designed for devices that don't have access to a web browser (if you've ever authenticated an app on your TV, this is probably the flow you've used), but it also works well from within R.
Learn more about the overall OAuth authentication flow in https://httr2.r-lib.org/articles/oauth.html.
req_oauth_device(
req,
client,
auth_url,
scope = NULL,
auth_params = list(),
token_params = list(),
cache_disk = FALSE,
cache_key = NULL
)
oauth_flow_device(
client,
auth_url,
pkce = FALSE,
scope = NULL,
auth_params = list(),
token_params = list()
)
req |
A httr2 request object. |
client |
An |
auth_url |
Authorization url; you'll need to discover this by reading the documentation. |
scope |
Scopes to be requested from the resource owner. |
auth_params |
A list containing additional parameters passed to
|
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. |
pkce |
Use "Proof Key for Code Exchange"? This adds an extra layer of security and should always be used if supported by the server. |
req_oauth_device()
returns a modified HTTP request that will
use OAuth; oauth_flow_device()
returns an oauth_token.
req_auth_github <- function(req) {
req_oauth_device(
req,
client = example_github_client(),
auth_url = "https://github.com/login/device/code"
)
}
request("https://api.github.com/user") |>
req_auth_github()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.