blib/lib/PEF/Front/Oauth/Google.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 59 CC 2 SCAR 9.6
CC
2
Cov
0%
_parse_user_info
6.0
_authorization_server
2.0
_required_redirect_uri
2.0
CRAP 2.6
1 package PEF::Front::Oauth::Google;
2  
3 use strict;
4 use warnings;
5 use base 'PEF::Front::Oauth';
6 use HTTP::Request::Common;
7 use feature 'state';
8 use PEF::Front::Config;
9  
10 sub _authorization_server {
11 'https://accounts.google.com/o/oauth2/auth';
12 }
13  
14 sub _required_redirect_uri { 1 }
15  
16 sub _token_request {
17 my ($self, $code) = @_;
18 POST 'https://accounts.google.com/o/oauth2/token',
19 [ redirect_uri => $self->{session}->data->{oauth_redirect_uri}{$self->{service}},
20 grant_type => 'authorization_code',
21 code => $code,
22 client_id => cfg_oauth_client_id($self->{service}),
23 client_secret => cfg_oauth_client_secret($self->{service})
24 ];
25  
26 }
27  
28 sub _get_user_info_request {
29 my ($self) = @_;
30 my $req = GET 'https://www.googleapis.com/oauth2/v2/userinfo',
31 Authorization => 'Bearer ' . $self->{session}->data->{oauth_access_token}{$self->{service}};
32 $req;
33 }
34  
35 sub _parse_user_info {
36 my ($self) = @_;
37 my $info = $self->{session}->data->{oauth_info_raw}{$self->{service}};
38 my @avatar = ();
39 @avatar = ({url => $info->{picture}}) if $info->{picture};
40 return {
41 name => $info->{name} || '',
42 email => $info->{email} || '',
43 login => $info->{email} || '',
44 avatar => \@avatar,
45 };
46 }
47  
48 sub new {
49 my ($class, $self) = @_;
50 bless $self, $class;
51 }
52  
53 1;