NAME

HTTP::API::Core::Auth - Small authentication helpers for HTTP::API::Core

SYNOPSIS

use HTTP::API::Core;
use HTTP::API::Core::Auth qw(bearer_auth);

my $api = HTTP::API::Core->new(
    base_url => 'https://api.example.com',
    hooks => {
        before_request => bearer_auth($token),
    },
);

DESCRIPTION

This module provides small lifecycle-hook helpers for common API authentication schemes. It deliberately builds on HTTP::API::Core's existing hook mechanism instead of adding OAuth flows or service-specific authentication behavior to the client core.

FUNCTIONS

bearer_auth($token)

Returns a before_request hook that adds an Authorization Bearer header unless an Authorization header is already present.

basic_auth($username, $password)

Returns a before_request hook that adds an HTTP Basic Authorization header.

api_key_auth(name => ..., value => ..., in => 'header'|'query')

Returns a before_request hook for API-key authentication. in defaults to header. Explicit request headers or an existing query parameter take precedence over the helper.

OAuth token acquisition and refresh are intentionally outside this module's scope.