App-WatchLater

 view release on metacpan or  search on metacpan

bin/yt-oauth  view on Meta::CPAN


  # setup a pipe and fork
  if (open my $fh, '-|') {
    # parent
    return ($port, $fh);
  } else {
    # child
    listen $sock, SOMAXCONN;
    accept(my $client, $sock);

    # response displayed to user after credentials are obtained
    $client->autoflush(1);
    print $client qq(HTTP/1.1 200 OK\r\n);
    print $client qq(Content-Language: en-US\r\n);
    print $client qq(Content-Type: text/html\r\n);
    print $client qq(\r\n);
    print $client qq(<html lang="en"><body>\r\n);
    print $client qq(Successfully obtained OAuth credentials.\r\n);
    print $client qq(This page may be closed.\r\n);
    print $client qq(</body></html>);

    # print credentials to pipe
    my $response = <$client>;
    print $response;
    exit;
  }
}

sub authenticate {
  my ($port, $fh) = start_http_listener;

  my $oauth_url = OAUTH_URL_TEMPLATE;

bin/yt-oauth  view on Meta::CPAN


=head1 DESCRIPTION

Authenticate with Google APIs using OAuth2. Retrieves an access token and a
refresh token. Access token can be used to authorize API requests, and
furthermore provides access to user data. Access tokens will expire, so a new
one can be requested using the refresh token (B<--refresh-token>).

Client ID and client secret are mandatory, and may be provided on the command
line or by environment variable. A client ID and secret can be obtained from
Google's L<API Console|https://console.developers.google.com/apis/credentials>.

=head1 OPTIONS

=over 4

=item B<-i> I<id>, B<--client-id>=I<id>

=item B<-s> I<secret>, B<--client-secret>=I<secret>

=item B<-t> I<token>, B<--refresh-token>=I<token>

lib/App/WatchLater/YouTube.pm  view on Meta::CPAN

=cut

our $VERSION = '0.03';


=head1 SYNOPSIS

This is a simple module for making requests to the YouTube Data API.
Authorization is required, and can be obtained by registering for an API key
from the Google Developer L<API
Console|https://console.developers.google.com/apis/credentials>. Alternatively,
obtain user authorization through OAuth2 using the yt-oauth(1) script.

    my $api = App::WatchLater::YouTube->new(
        access_token => ...,
        api_key      => ...,
    );

    # returns the body of the HTTP response as a string
    my $body = $api->request('GET', '/videos', {
      id => 'Ks-_Mh1QhMc',



( run in 0.461 second using v1.01-cache-2.11-cpan-4d50c553e7e )