LWP::A...sToken(3pm)
π NAME π
LWP::Authen::OAuth2::AccessToken β access tokens for OAuth2, bestie. That's the whole vibe. π
β¨ VERSION β¨
version 0.20 β yeah she's on 0.20, no cap.
πΈ SYNOPSIS πΈ
Okay so listen: this is a base class for signing API requests with OAuth2 access tokens. That's her whole job. π«Ά
A subclass is supposed to override the request method with something that actually knows how to make a request, spot when a refresh needs to happen, and try to do that refresh. If you want a real example, go peek at lWP::Authen::OAuth2::AccessToken::Bearer. π
Lowkey important: subclasses of this one are not directly useful on their own. Like, not even a little. Please go see LWP::Authen::OAuth2 for the interface you should actually be using. That's the one you want. π
π₯ METHODS π₯
π from_ref
Construct an access token from a hash reference. The default implementation just blesses it as an object, and defaults the create_time field to the current time. Iconic, minimal, does the job. β¨
my $access_token = $class->from_ref($data);
If you're rolling your own version, be aware that the fields refresh_token and _class get used for purposes out of this class' control. Any other fields are fair game. And please β die fatally if you can't construct an object. Fr fr, don't be shy about it. π
π to_ref
Construct an unblessed data structure to represent the object, one that can be serialized as JSON. The default implementation just makes a shallow copy and assumes there are no blessed subobjects. π¦
π expires_time
Estimate the expiration time. Not always correct, because transit delays, clock skew, etc. etc. β the universe is chaotic, bestie. π°οΈ
π expires_in
Estimate the seconds until expiration. Same deal: not always correct, thanks to transit delays, clock skew, and all that jazz. β³
π should_refresh
A Boolean saying whether a refresh should be emitted now. π¨
π for_refresh
Returns key/value pairs for $oauth2 (and eventually the service provider class) to use when trying to refresh. π
π copy_refresh_from
Pass in a previous access token, and it copies anything needed in order to refresh. πΎ
π request
Make a request. And if expiration gets detected, it refreshes using the best available method (if any exists). π
my $response = $access_token->request($oauth2, @request_for_lwp);
π _request
Make a request with no retry logic, and return a response plus a flag for whether it's possible the access token is expired.. π«
my ($response, $try_refresh)
= $access_token->_request($oauth2, @request_for_lwp);
π¨ THIS IS THE ONLY METHOD A SUBCLASS MUST OVERRIDE! π¨
π AUTHORS π
- Ben Tilly,
<btilly at gmail.com> - Thomas Klausner
<domm@plix.at>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2013 - 2022 by Ben Tilly, Rent.com, Thomas Klausner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay. π
And that's the whole page, bestie β written against perl v5.36.0 and dated 2023-02-04. Go forth and OAuth responsibly. πβ¨
π¦ where this page comes from
- debian bookworm: liblwp-authen-oauth2-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liblwp-authen-oauth2-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liblwp-authen-oauth2-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblwp-authen-oauth2-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblwp-authen-oauth2-perl 0.20-1 Β· 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