line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LWP::Authen::OAuth2::ServiceProvider::Withings; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Withings OAuth2 |
4
|
|
|
|
|
|
|
our $VERSION = '0.18'; our $VERSION = '0.19'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
678
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
4
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(LWP::Authen::OAuth2::ServiceProvider); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub authorization_endpoint { |
13
|
1
|
|
|
1
|
1
|
2
|
return ' https://account.withings.com/oauth2_user/authorize2'; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub token_endpoint { |
17
|
1
|
|
|
1
|
1
|
18
|
return 'https://wbsapi.withings.net/v2/oauth2'; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub authorization_required_params { |
21
|
1
|
|
|
1
|
0
|
3
|
return ( 'client_id', 'state', 'scope', 'redirect_uri', 'response_type' ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub authorization_default_params { |
25
|
1
|
|
|
1
|
0
|
4
|
return ( response_type => 'code', state => 'auth', scope => 'user.metrics' ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub request_required_params { |
29
|
1
|
|
|
1
|
0
|
4
|
return ( 'action', 'grant_type', 'client_id', 'client_secret', 'code', 'redirect_uri' ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub request_default_params { |
33
|
1
|
|
|
1
|
0
|
4
|
return ( grant_type => 'authorization_code', action => 'requesttoken' ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub refresh_required_params { |
37
|
1
|
|
|
1
|
0
|
14
|
return ( 'action', 'grant_type', 'client_id', 'client_secret', 'refresh_token' ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub refresh_default_params { |
41
|
1
|
|
|
1
|
0
|
3
|
return ( grant_type => 'refresh_token', action => 'requesttoken' ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub construct_tokens { |
45
|
0
|
|
|
0
|
0
|
|
my ( $self, $oauth2, $response ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $content = eval { decode_json( $response->content ) }; |
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$content = $content->{ 'body' }; |
49
|
0
|
|
|
|
|
|
$response->content( encode_json( $content ) ); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$self->SUPER::construct_tokens( $oauth2, $response ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |