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: 0x559f428d9678>
#> <environment: 0x559f44934918>
#>
#> 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: 0x559f449f6748>
#> <environment: 0x559f449f9b30>
#>
#> 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: 0x559f44a512c0>
#> <environment: 0x559f44a509c8>
#>
#> 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: 0x559f44a85030>
#> <environment: 0x559f44a84700>
#>
#> attr(,"class")
#> [1] "apifetch_auth"