use LWP::Authen::Oauth2; use Storable; #to save and restore token for future use use Term::Prompt; use strict; use warnings; my $oauth2 = LWP::Authen::OAuth2->new( client_id => '*****', client_secret => '*****', redirect_uri => 'I don't even know', scope => 'fspt-w', response_type => 'id_token' ); my $url = $oauth2->authorization_url('https://api.login.yahoo.com/oauth2/request_auth'); my $code = prompt('x', 'Paste the code obtained at the above URL here: ', '', ''); # Exchange the code for an access token: my $token = $oauth2->get_access_token($code) or die; # If we get to here, it worked! Report success: print "\nToken obtained successfully!\n"; print "Here are the token contents (just FYI):\n\n"; print $token->to_string, "\n";