#!/usr/bin/env perl

# PODNAME: freebox-authorize
#
# ABSTRACT: Helper script to obtain Freebox app authorization token.


use strict;
use warnings;

use WebService::Freebox;

if (@ARGV != 4) {
    die "Usage: $0 <app-id> <app-name> <app-version> <device>\n";
}

my $fb = WebService::Freebox->new(app_id => $ARGV[0], app_version => $ARGV[2]);

$|++;
print "Requesting authorization, please grant it using Freebox keys.\n";

my $app_token = $fb->authorize($ARGV[1], $ARGV[3]);

print qq{Successfully obtained app token "$app_token"\n};

exit 0

__END__
=pod

=head1 NAME

freebox-authorize - Helper script to obtain Freebox app authorization token.

=head1 VERSION

version 0.001

=head1 SYNOPSIS

freebox-authorize <app-id> <app-name> <app-version> <device>

For example:

    freebox-authorize org.cpan.freebox.test "Test Freebox app" 1.0 "My computer"

All parameters are required.

=head1 DESCRIPTION

The script uses L<WebService::Freebox> to request authorization to use the
Freebox API for the application with the given name and version from the
specified device.

=head1 AUTHOR

Vadim Zeitlin <vz-cpan@zeitlins.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Vadim Zeitlin.

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

=cut

