File Coverage

lib/LWP/Authen/OAuth2/ServiceProvider/Withings.pm
Criterion Covered Total %
statement 17 23 73.9
branch n/a
condition n/a
subroutine 11 12 91.6
pod 2 9 22.2
total 30 44 68.1


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.20'; # VERSION
5              
6 1     1   978 use strict;
  1         3  
  1         33  
7 1     1   6 use warnings;
  1         3  
  1         30  
8 1     1   6 use JSON;
  1         3  
  1         8  
9              
10             our @ISA = qw(LWP::Authen::OAuth2::ServiceProvider);
11              
12             sub authorization_endpoint {
13 1     1 1 4 return ' https://account.withings.com/oauth2_user/authorize2';
14             }
15              
16             sub token_endpoint {
17 1     1 1 6 return 'https://wbsapi.withings.net/v2/oauth2';
18             }
19              
20             sub authorization_required_params {
21 1     1 0 4 return ( 'client_id', 'state', 'scope', 'redirect_uri', 'response_type' );
22             }
23              
24             sub authorization_default_params {
25 1     1 0 7 return ( response_type => 'code', state => 'auth', scope => 'user.metrics' );
26             }
27              
28             sub request_required_params {
29 1     1 0 17 return ( 'action', 'grant_type', 'client_id', 'client_secret', 'code', 'redirect_uri' );
30             }
31              
32             sub request_default_params {
33 1     1 0 5 return ( grant_type => 'authorization_code', action => 'requesttoken' );
34             }
35              
36             sub refresh_required_params {
37 1     1 0 12 return ( 'action', 'grant_type', 'client_id', 'client_secret', 'refresh_token' );
38             }
39              
40             sub refresh_default_params {
41 1     1 0 4 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__