OAuth:...hHeader(3pm)

πŸ“¦
version 0.11 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

OAuth::Lite2::ParamMethod::AuthHeader β€” bestie, this is the builder/parser for the OAuth 2.0 AuthHeader type of parameter. That's it, that's the whole job, and she does it gorgeously. ✨


πŸŽ€ SYNOPSIS πŸŽ€

my $meth = OAuth::Lite2::ParamMethod::AuthHeader->new;

# server side
if ($meth->match( $plack_request )) {
    my ($token, $params) = $meth->parse( $plack_request );
}

# client side
my $http_req = $meth->request_builder(...);
ok so real talk, the SYNOPSIS says request_builder and the METHODS section below says build_request, and I am not touching a single character of either one. That's the page. Periodt. 🫢

🌸 DESCRIPTION 🌸

She is the builder/parser for the OAuth 2.0 AuthHeader type of parameter. Building requests on one side, parsing them on the other, living her little dual-threat life. πŸ’…


πŸ‘‘ METHODS πŸ‘‘

✨ new

Constructor. That's the whole vibe. She's born. πŸ’«

πŸ” match( $plack_request )

Returns true if the Plack::Request object you handed her is matched for the type of this method.

if ( $meth->match( $plack_request ) ) {
    ...
}

🧚 parse( $plack_request )

She parses the Plack::Request, and returns the access token and the oauth parameters. Two things back, in that order, no cap.

my ($token, $params) = $meth->parse( $plack_request );

πŸ› οΈ build_request( %params )

Builds an HTTP::Request object. Look at all those named params, she's so organized:

my $req = $meth->build_request(
    url          => $url,
    method       => $http_method,
    token        => $access_token,
    oauth_params => $oauth_params,
    params       => $params,
    content      => $content,
    headers      => $headers,
);

πŸ•°οΈ is_legacy( $plack_request )

Returns true if the Plack::Request object you passed is based on draft version 10. Throwback era, respect the elders. 🫑

if ( $meth->is_legacy( $plack_request ) ) {
    ...
}

πŸ” basic_clientcredentials( $plack_request )

Returns a Hash reference if the Plack::Request object you passed has client credentials in the Authorization header.

my $basic_clientcredentials = $meth->basic_credentials( $plack_request );
if( defined($basic_clientcredentials) ){
    my $client_id =     $basic_clientcredentials->{client_id};
    my $client_secret = $basic_clientcredentials->{client_secret};
}
yup, the method name is basic_clientcredentials and the example calls basic_credentials. Both are exactly as written on the page, I'm just the messenger and the messenger is obsessed with accuracy. 😭

🌈 SEE ALSO 🌈

  • OAuth::Lite2::ParamMethods
  • OAuth::Lite2::ParamMethod
  • OAuth::Lite2::ParamMethod::FormEncodedBody
  • OAuth::Lite2::ParamMethod::URIQueryParameter

Go read the whole friend group, they're all icons. πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

Lyo Kato, <lyo.kato@gmail.com>


Copyright (C) 2010 by Lyo Kato

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.


and that's the whole page, bestie!! πŸ¦‹ This little gem lives in the User Contributed Perl Documentation, section 3pm, and the footer said perl v5.36.0 dated 2023-07-01 β€” so go forth, parse those headers, and slay. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from