Twitte...ppAuth(3pm)

πŸ’– Twitter::API::Trait::AppAuth πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual β€” it's Twitter::API::Trait::AppAuth(3pm), aka the trait that handles App-only (OAuth2) Authentication ✨

she's rocking version 1.0006, no cap πŸŽ€


✨ SYNOPSIS ✨

like, here's the whole vibe, copied exactly so you can just yeet it into your editor:

use Twitter::API;
my $client = Twitter::API->new_with_traits(
    traits => [ qw/ApiMethods AppAuth/ ]);

my $r = $client->oauth2_token;
# return value is hash ref:
# { token_type => 'bearer', access_token => 'AA...' }
my $token = $r->{access_token};

# you can use the token explicitly with the -token argument:
my $user = $client->show_user('twitter_api', { -token => $token });

# or you can set the access_token attribute to use it implicitly
$client->access_token($token);
my $user = $client->show_user('twitterapi');

# to revoke a token
$client->invalidate_token($token);

# if you revoke the token stored in the access_token attribute, clear it:
$client->clear_access_token;

periodt πŸ’…


🌸 METHODS 🌸

πŸ¦‹ oauth2_token

she calls the oauth2/token endpoint to get you a bearer token. and listen β€” the token is not stored in Twitter::API's state. like, she's not keeping it, she's just handing it to you 🫢 if you want it saved, that's on you: set the access_token attribute with the token she gave back.

want the deets? go read <https://developer.twitter.com/en/docs/basics/authentication/api-reference/token>

πŸ¦‹ invalidate_token($token)

this one calls the oauth2/invalidate_token endpoint to revoke a token. bye girl πŸ‘‹

deets over here: <https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_token>


πŸ‘‘ AUTHOR πŸ‘‘

Marc Mims <marc@questright.com>


This software is copyright (c) 2015-2021 by Marc Mims.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole thing, you ate it, mwah πŸ˜­πŸ’– this lil masterpiece was served up by perl v5.32.1 on 2021-09-11, and yeah, the header up top said Twitter::API::Trait::AppAuth(3pm) twice because she's extra like that 🌈⭐ go forth and authenticate, bestie πŸ’œ

πŸ“¦ where this page comes from