line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12984
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mojolicious::Plugin::Web::Auth::Site::Fitbit; |
5
|
|
|
|
|
|
|
$Mojolicious::Plugin::Web::Auth::Site::Fitbit::VERSION = '0.000002'; |
6
|
1
|
|
|
1
|
|
381
|
use Mojo::Base qw/Mojolicious::Plugin::Web::Auth::OAuth2/; |
|
1
|
|
|
|
|
6741
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has authorize_header => 'Bearer '; |
9
|
|
|
|
|
|
|
has response_type => 'code'; |
10
|
|
|
|
|
|
|
has user_info => 1; |
11
|
|
|
|
|
|
|
has user_info_url => 'https://api.fitbit.com/1/user/-/profile.json'; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
0
|
|
sub moniker { 'fitbit' } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
1; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=pod |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=encoding UTF-8 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Mojolicious::Plugin::Web::Auth::Site::Fitbit - Fitbit OAuth Plugin for Mojolicious::Plugin::Web::Auth |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
version 0.000002 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use URI::FromHash qw( uri ); |
32
|
|
|
|
|
|
|
my $key = 'foo'; |
33
|
|
|
|
|
|
|
my $secret = 'seekrit'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $access_token_url = uri( |
36
|
|
|
|
|
|
|
scheme => 'https', |
37
|
|
|
|
|
|
|
username => $key, |
38
|
|
|
|
|
|
|
password => $secret, |
39
|
|
|
|
|
|
|
host => 'api.fitbit.com', |
40
|
|
|
|
|
|
|
path => 'oauth2/token', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $authorize_url = uri( |
44
|
|
|
|
|
|
|
scheme => 'https', |
45
|
|
|
|
|
|
|
username => $key, |
46
|
|
|
|
|
|
|
password => $secret, |
47
|
|
|
|
|
|
|
host => 'www.fitbit.com', |
48
|
|
|
|
|
|
|
path => 'oauth2/authorize', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Mojolicious |
52
|
|
|
|
|
|
|
$self->plugin( |
53
|
|
|
|
|
|
|
'Web::Auth', |
54
|
|
|
|
|
|
|
module => 'Fitbit', |
55
|
|
|
|
|
|
|
authorize_url => $authorize_url, |
56
|
|
|
|
|
|
|
access_token_url => $access_token_url, |
57
|
|
|
|
|
|
|
key => $key, |
58
|
|
|
|
|
|
|
scope => |
59
|
|
|
|
|
|
|
'activity heartrate location nutrition profile sleep social weight', |
60
|
|
|
|
|
|
|
on_finished => sub { |
61
|
|
|
|
|
|
|
my ( $c, $access_token, $access_secret ) = @_; |
62
|
|
|
|
|
|
|
...; |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Mojolicious::Lite |
67
|
|
|
|
|
|
|
plugin 'Web::Auth', |
68
|
|
|
|
|
|
|
module => 'Fitbit', |
69
|
|
|
|
|
|
|
authorize_url => $authorize_url, |
70
|
|
|
|
|
|
|
access_token_url => $access_token_url, |
71
|
|
|
|
|
|
|
key => $key, |
72
|
|
|
|
|
|
|
scope => |
73
|
|
|
|
|
|
|
'activity heartrate location nutrition profile sleep social weight', |
74
|
|
|
|
|
|
|
on_finished => sub { |
75
|
|
|
|
|
|
|
my ( $c, $access_token, $access_secret ) = @_; |
76
|
|
|
|
|
|
|
...; |
77
|
|
|
|
|
|
|
}; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# default authentication endpoint: /auth/fitbit/authenticate |
80
|
|
|
|
|
|
|
# default callback endpoint: /auth/fitbit/callback |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This module adds L support to |
85
|
|
|
|
|
|
|
L. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Olaf Alders |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Olaf Alders. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
96
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |