OAuth:...::Error(3pm)
π OAuth::Lite2::Server::Error π
okay bestie, so this is a page from the User Contributed Perl Documentation collection, and it's all about OAuth::Lite2::Server::Error β the OAuth 2.0 server error classes. if you're building an OAuth 2.0 server in Perl and something goes wrong (and it will, it always does π), these are the error objects you'll be throwing around. let's get into it π«Ά
β¨ NAME β¨
OAuth::Lite2::Server::Error β OAuth 2.0 server errors. that's it, that's the whole vibe. it's giving "errors, but make them classy" π
πΈ SYNOPSIS πΈ
ok so here's how you actually use this thing. two spots matter: the End-User Endpoint and the token-endpoint. catch the error, check the type, bounce the params back. periodt.
# At End-User Endpoint
try {
if ($something_wrong) {
OAuth::Lite2::Server::Error::InvalidRequest->throw(
description => q{Something wrong},
# state => q{foo},
);
}
} catch {
if ($_->isa("OAuth::Lite2::Server::Error")) {
my $uri = URI->new( $client_callback_uri );
my %error_params = ( error => $_->type );
$error_params{error_description} = $_->description if $_->description;
$error_params{state} = $_->state if $_->state;
$uri->query_form(%error_params);
$your_app->redirect( $uri->as_string );
} else {
# Internal Server Error
}
};
# At token-endpoint
try {
} catch {
if ($_->isa("OAuth::Lite2::Server::Error")) {
my %error_params = ( error => $_->type );
$error_params{error_description} = $_->description if $_->description;
$error_params{scope} = $_->scope if $_->scope;
$req->new_response($_->code,
[ "Content-Type" => $formatter->type, "Cache-Control" => "no-store" ],
[ $formatter->format(\%error_params) ],
);
} else {
# rethrow
die $_;
}
};
see how at the end-user endpoint you redirect with the error params stuffed into the callback URI, and at the token-endpoint you build a fresh response with the right code and Cache-Control => "no-store"? that's the whole move. also note the # rethrow β if it's not one of ours, you die $_ and let it fly, no cap. π¦
π DESCRIPTION π
these are the OAuth 2.0 error classes. literally what it says on the tin.
if you wanna read the actual spec (and honestly, iconic of you), the refs are here:
π METHODS π
there are following errors. yes bestie, that's genuinely the whole description β the errors are the methods here. it's giving minimalist β¨
π ERRORS π
here's the full roster, all of them, no skipping, we don't gatekeep:
OAuth::Lite2::Server::Error::InvalidRequestOAuth::Lite2::Server::Error::InvalidClientOAuth::Lite2::Server::Error::UnauthorizedClientOAuth::Lite2::Server::Error::RedirectURIMismatchOAuth::Lite2::Server::Error::AccessDeniedOAuth::Lite2::Server::Error::UnsupportedResponseTypeOAuth::Lite2::Server::Error::UnsupportedResourceTypeOAuth::Lite2::Server::Error::InvalidGrantOAuth::Lite2::Server::Error::UnsupportedGrantTypeOAuth::Lite2::Server::Error::InvalidScopeOAuth::Lite2::Server::Error::InvalidTokenOAuth::Lite2::Server::Error::ExpiredTokenLegacyOAuth::Lite2::Server::Error::ExpiredTokenOAuth::Lite2::Server::Error::InsufficientScopeOAuth::Lite2::Server::Error::InvalidServerStateOAuth::Lite2::Server::Error::TemporarilyUnavailableOAuth::Lite2::Server::Error::ServerError
seventeen of them. that's the whole squad. screenshot it, memorize it, whatever you gotta do πΈ
π AUTHOR π
the legends behind this:
- Ryo Ito, <ritou.06@gmail.com>
- Lyo Kato, <lyo.kato@gmail.com>
π§ COPYRIGHT AND LICENSE π§
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.
lowkey the "same terms as Perl itself" thing is doing a lot of heavy lifting there, but okay, that's the license, we respect it π
and that's the whole page, bestie! this was OAuth::Lite2::Server::Error(3pm) from the User Contributed Perl Documentation, documented as of 2023-07-01 and shipped alongside perl v5.36.0. go forth and throw errors responsibly, mwah πβ¨πΈ
π¦ where this page comes from
- debian trixie: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms