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