Constructors describing how a token is attached to a request. Pass the result
to the auth argument of af_api().
Usage
af_auth_raw(header = "Authorization")
af_auth_bearer(header = "Authorization", prefix = "Bearer ")
af_auth_header(header = "X-API-Key")
af_auth_query(param = "api_key")Details
af_auth_raw(): send the token verbatim in a header (defaultAuthorization). This is what the Big Data PE API expects.af_auth_bearer(): send"Bearer <token>"in theAuthorizationheader.af_auth_header(): send the token in an arbitrary header (e.g.X-API-Key).af_auth_query(): send the token as a URL query parameter.
Examples
af_auth_raw()
#> $apply
#> function (req, token)
#> {
#> h <- stats::setNames(list(token), header)
#> do.call(httr2::req_headers, c(list(req), h))
#> }
#> <bytecode: 0x55d8bc1dc8a0>
#> <environment: 0x55d8bd01af98>
#>
#> attr(,"class")
#> [1] "apifetch_auth"
af_auth_bearer()
#> $apply
#> function (req, token)
#> {
#> h <- stats::setNames(list(paste0(prefix, token)), header)
#> do.call(httr2::req_headers, c(list(req), h))
#> }
#> <bytecode: 0x55d8bcfc7b90>
#> <environment: 0x55d8bcfc4ab8>
#>
#> attr(,"class")
#> [1] "apifetch_auth"
af_auth_header("X-API-Key")
#> $apply
#> function (req, token)
#> {
#> h <- stats::setNames(list(token), header)
#> do.call(httr2::req_headers, c(list(req), h))
#> }
#> <bytecode: 0x55d8bcf4ea88>
#> <environment: 0x55d8bcf4f3f0>
#>
#> attr(,"class")
#> [1] "apifetch_auth"
af_auth_query("api_key")
#> $apply
#> function (req, token)
#> {
#> q <- stats::setNames(list(token), param)
#> do.call(httr2::req_url_query, c(list(req), q))
#> }
#> <bytecode: 0x55d8bcdb9f90>
#> <environment: 0x55d8bcdb69f8>
#>
#> attr(,"class")
#> [1] "apifetch_auth"