File: dropbox

package info (click to toggle)
libnet-dropbox-api-perl 1.9-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 268 kB
  • sloc: perl: 2,424; makefile: 7
file content (45 lines) | stat: -rwxr-xr-x 1,066 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env perl

use FindBin;
use Mojolicious::Lite;
use lib "$FindBin::Bin/../lib";
use Net::Dropbox::API;
use Data::Dumper;

my $box = Net::Dropbox->new({key => 'KEY', secret=>'SECRET'});
my $pending;

get '/' => sub  {
    my $self = shift;
    $self->stash->{login} = $box->login;
    $pending->{$box->request_token} = $box->request_secret;
} => 'index';

get '/callback?:stuff' => sub  {
    my $self = shift;
    app->log->debug($self->param('oauth_token'));
    my $secret = delete $pending->{$self->param('oauth_token')};
    $box->auth({request_token => $self->param('oauth_token'), request_secret => $secret});

    $box->context('dropbox');
    my $response = $box->list;
    app->log->debug(Dumper($response));
    $self->render_text(Dumper($response), layout => 'default');
};

app->start;
__DATA__

@@ index.html.ep
% layout 'default';
<a href="<%= $login %>">login to dropbox</a>

@@ layouts/default.html.ep
<!doctype html><html>
    <head><title>Funky!</title></head>
    <body>
      <pre>
      <%== content %>
      </pre>
    </body>
</html>