% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/oauth-flow-jwt.R
\name{req_oauth_bearer_jwt}
\alias{req_oauth_bearer_jwt}
\alias{oauth_flow_bearer_jwt}
\title{OAuth with a bearer JWT (JSON web token)}
\usage{
req_oauth_bearer_jwt(
  req,
  client,
  claim,
  signature = "jwt_encode_sig",
  signature_params = list(),
  scope = NULL,
  token_params = list()
)

oauth_flow_bearer_jwt(
  client,
  claim,
  signature = "jwt_encode_sig",
  signature_params = list(),
  scope = NULL,
  token_params = list()
)
}
\arguments{
\item{req}{A \link{request}.}

\item{client}{An \code{\link[=oauth_client]{oauth_client()}}.}

\item{claim}{A list of claims. If all elements of the claim set are static
apart from \code{iat}, \code{nbf}, \code{exp}, or \code{jti}, provide a list and
\code{\link[=jwt_claim]{jwt_claim()}} will automatically fill in the dynamic components.
If other components need to vary, you can instead provide a zero-argument
callback function which should call \code{jwt_claim()}.}

\item{signature}{Function use to sign \code{claim}, e.g. \code{\link[=jwt_encode_sig]{jwt_encode_sig()}}.}

\item{signature_params}{Additional arguments passed to \code{signature}, e.g.
\code{size}, \code{header}.}

\item{scope}{Scopes to be requested from the resource owner.}

\item{token_params}{List containing additional parameters passed to the
\code{token_url}.}
}
\value{
\code{req_oauth_bearer_jwt()} returns a modified HTTP \link{request} that will
use OAuth; \code{oauth_flow_bearer_jwt()} returns an \link{oauth_token}.
}
\description{
Authenticate using a \strong{Bearer JWT} (JSON web token) as an authorization
grant to get an access token, as defined by \href{https://datatracker.ietf.org/doc/html/rfc7523#section-2.1}{Section 2.1 of RFC 7523}.
It is often used for service accounts, accounts that are used primarily in
automated environments.

Learn more about the overall OAuth authentication flow in \code{vignette("oauth")}.
}
\examples{
req_auth <- function(req) {
  req_oauth_bearer_jwt(
    req,
    client = oauth_client("example", "https://example.com/get_token"),
    claim = jwt_claim()
  )
}

request("https://example.com") |>
 req_auth()
}
\seealso{
Other OAuth flows: 
\code{\link{req_oauth_auth_code}()},
\code{\link{req_oauth_client_credentials}()},
\code{\link{req_oauth_password}()},
\code{\link{req_oauth_refresh}()}
}
\concept{OAuth flows}
