
OAuth with client credentials
Source:R/oauth-flow-client-credentials.R
req_oauth_client_credentials.RdAuthenticate using OAuth client credentials flow, as defined by Section 4.4 of RFC 6749. It is used to allow the client to access resources that it controls directly, not on behalf of an user.
Learn more about the overall OAuth authentication flow in https://httr2.r-lib.org/articles/oauth.html.
Arguments
- req
A httr2 request object.
- client
An
oauth_client().- scope
Scopes to be requested from the resource owner.
- token_params
List containing additional parameters passed to the
token_url.- expiry_margin
Number of seconds before a token's stated expiry that it should be treated as expired. Increase this for servers that reject tokens shortly before they expire. Defaults to 30 seconds.
Value
req_oauth_client_credentials() returns a modified HTTP request that will
use OAuth; oauth_flow_client_credentials() returns an oauth_token.
Examples
req_auth <- function(req) {
req_oauth_client_credentials(
req,
client = oauth_client("example", "https://example.com/get_token")
)
}
request("https://example.com") |>
req_auth()
#> <httr2_request>
#> GET https://example.com
#> Body: empty
#> Policies:
#> * auth_sign : <list>
#> * auth_oauth: TRUE