| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package LWP::Authen::OAuth2::ServiceProvider::Line; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # ABSTRACT: Access Line OAuth2 API v2 | 
| 4 |  |  |  |  |  |  | our $VERSION = '0.18'; # VERSION | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 721 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 25 |  | 
| 7 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 4 | use parent 'LWP::Authen::OAuth2::ServiceProvider'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub required_init { | 
| 12 | 1 |  |  | 1 | 1 | 3 | return qw(client_id client_secret redirect_uri); | 
| 13 |  |  |  |  |  |  | } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub authorization_required_params { | 
| 16 | 1 |  |  | 1 | 0 | 3 | return qw(client_id redirect_uri response_type state); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub authorization_default_params { | 
| 20 | 1 |  |  | 1 | 0 | 3 | return response_type => 'code'; | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub request_required_params { | 
| 24 | 1 |  |  | 1 | 0 | 3 | return qw(client_id redirect_uri grant_type client_secret code); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub request_default_params { | 
| 28 | 1 |  |  | 1 | 0 | 3 | return grant_type => 'authorization_code'; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub init { | 
| 32 | 1 |  |  | 1 | 1 | 2 | my ($self, $opts) = @_; | 
| 33 | 1 |  |  |  |  | 6 | $self->copy_option($opts, line_server => 'line.me'); | 
| 34 | 1 |  |  |  |  | 5 | $self->SUPER::init($opts); | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub authorization_endpoint { | 
| 38 | 2 |  |  | 2 | 1 | 4 | my $self = shift; | 
| 39 | 2 | 50 |  |  |  | 6 | my $server = $self->{line_server} or die 'line_server not configured. Forgot to call init()?'; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 2 |  |  |  |  | 7 | return "https://access.$server/dialog/oauth/weblogin"; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | sub token_endpoint { | 
| 45 | 2 |  |  | 2 | 1 | 4 | my $self = shift; | 
| 46 | 2 | 50 |  |  |  | 12 | my $server = $self->{line_server} or die 'line_server not configured. Forgot to call init()?'; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 2 |  |  |  |  | 10 | return "https://api.$server/v2/oauth/accessToken"; | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub api_url_base { | 
| 52 | 1 |  |  | 1 | 0 | 360 | my $self = shift; | 
| 53 | 1 | 50 |  |  |  | 4 | my $server = $self->{line_server} or die 'line_server not configured. Forgot to call init()?'; | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 1 |  |  |  |  | 5 | return "https://api.$server/v2/"; | 
| 56 |  |  |  |  |  |  | } | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | sub access_token_class { | 
| 59 | 1 |  |  | 1 | 1 | 3 | my ($self, $type) = @_; | 
| 60 |  |  |  |  |  |  |  | 
| 61 | 1 | 50 |  |  |  | 4 | if ($type eq 'bearer') { | 
| 62 | 1 |  |  |  |  | 4 | return 'LWP::Authen::OAuth2::ServiceProvider::Line::AccessToken'; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 0 |  |  |  |  |  | return $self->SUPER::access_token_class($type); | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | 1; | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | __END__ |