Skip to contents

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")

Arguments

header

Header name to use.

prefix

String prepended to the token (bearer scheme).

param

Query-parameter name (query scheme).

Value

An apifetch_auth object.

Details

  • af_auth_raw(): send the token verbatim in a header (default Authorization). This is what the Big Data PE API expects.

  • af_auth_bearer(): send "Bearer <token>" in the Authorization header.

  • 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: 0x563a4d0891f0>
#> <environment: 0x563a4f150630>
#> 
#> 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: 0x563a4f0500e8>
#> <environment: 0x563a4f050d60>
#> 
#> 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: 0x563a4edda730>
#> <environment: 0x563a4ed969d0>
#> 
#> 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: 0x563a4ec464e0>
#> <environment: 0x563a4ec46e80>
#> 
#> attr(,"class")
#> [1] "apifetch_auth"