Net::O...rdGrant(3pm)
π Net::O...rdGrant(3pm) β Net::OAuth2::AuthorizationServer::PasswordGrant
okay so this page is straight out of the User Contributed Perl Documentation, file name Net::O...rdGrant(3pm), and bestieβ¦ it's giving "we need to talk" energy from the very first line. buckle up π
β¨ NAME β¨
Net::OAuth2::AuthorizationServer::PasswordGrant β the OAuth2 Resource Owner Password Credentials Grant π
π¨ You "MUST NOT" use this grant type (see <https://tools.ietf.org/html/draft-ietf-oauth-security-topics-15>). That's not me being dramatic, that's literally what the doc says. no cap. π
π¦ SYNOPSIS π¦
here's the whole vibe, copy it exactly bestie:
my $Grant = Net::OAuth2::AuthorizationServer::PasswordGrant->new(
clients => {
TrendyNewService => {
client_secret => 'TopSecretClientSecret',
scopes => {
post_images => 1,
annoy_friends => 1,
},
},
},
users => {
bob => 'j$s03R#!\fs',
tom => 'dE0@@s^tWg1',
},
);
# verify a client and username against known clients/users
my ( $client_id,$error,$scopes,$username ) = $Grant->verify_user_password(
client_id => $client_id,
client_secret => $client_secret,
username => $username,
password => $password,
scopes => [ qw/ list of scopes / ],
);
if ( ! $Grant->login_resource_owner ) {
# resource owner needs to login
...
}
# have resource owner confirm (and perhaps modify) scopes
my ( $confirmed,$error,$scopes_ref ) = $Grant->confirm_by_resource_owner(
client_id => $client_id,
scopes => [ qw/ list of scopes / ],
);
# generate a token
my $token = $Grant->token(
client_id => $client_id,
scopes => $scopes_ref,
type => 'access', # one of: access, refresh
redirect_uri => $redirect_uri,
user_id => $user_id, # optional
jwt_claims_cb => sub { ... }, # optional, see jwt_claims_cb in Manual
);
# store access token
$Grant->store_access_token(
client_id => $client,
access_token => $access_token,
refresh_token => $refresh_token,
scopes => $scopes_ref,
old_refresh_token => $old_refresh_token,
);
# verify an access token
my ( $is_valid,$error ) = $Grant->verify_access_token(
access_token => $access_token,
scopes => $scopes_ref,
is_refresh_token => 0,
);
# or:
my ( $oauth_details,$error ) = $Grant->verify_token_and_scope(
refresh_token => $refresh_token,
auth_header => $http_authorization_header,
);
πΈ DESCRIPTION πΈ
so this module implements the OAuth2 "Resource Owner Password Credentials Grant" flow, exactly as described over at <http://tools.ietf.org/html/rfc6749#section-4.3> β¨
π CONSTRUCTOR ARGUMENTS π
along with all the ones detailed in "CONSTRUCTOR ARGUMENTS" in Net::OAuth2::AuthorizationServer::Manual, this grant type also supports the following, bestie:
π users
a hashref of client details, keyed like this:
$username => $password
that's it. username in, password out, iconic behavior fr fr π
π CALLBACK FUNCTIONS π
this grant type supports these callbacks:
login_resource_owner_cb
confirm_by_resource_owner_cb
verify_client_cb
verify_user_password_cb
store_access_token_cb
verify_access_token_cb
and if you need the deets on what each one actually does, go read "CALLBACK FUNCTIONS" in Net::OAuth2::AuthorizationServer::Manual. i'm not gatekeeping, it's all there π«Ά
π AUTHOR π
Lee Johnson - leejo@cpan.org β the main character who wrote this π
β LICENSE β
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself π and if you wanna contribute documentation or file a bug report, please raise an issue / pull request at:
https://github.com/Humanstate/net-oauth2-authorizationserver
and that's the whole page bestie!! π¦β¨ sperl v5.36.0, dated 2022-08-28, and this absolute legend of a manual page is Net::O...rdGrant(3pm). go forth, but remember β you MUST NOT actually use this grant type. mwah ππΈ
π¦ where this page comes from
- ubuntu noble: libnet-oauth2-authorizationserver-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-oauth2-authorizationserver-perl 0.28-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-oauth2-authorizationserver-perl 0.28-2 Β· 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