$param->{ua} = $class->_new_ua;
}
unless (defined $param->{json_parser}) {
$param->{json_parser} = $class->_new_json_parser;
}
bless { %$param }, $class;
}
sub build {
my
die 'could not get service document.' . $res->status_line;
}
my $document = $self->{json_parser}->decode($res->content);
$self->build_from_document($document, $discovery_service_url,
::API::Method->new(
ua => $self->{ua},
json_parser => $self->{json_parser},
base_url => $base_url,
doc =
e Google::API::OAuth2::SignedJWT;
use strict;
use warnings;
use HTTP::Request::Common;
use JSON;
use JSON::WebToken;
use constant OAUTH2_TOKEN_ENDPOINT => "https://accounts.google.com/o/oauth2/toke
my $json_response = $self->_get_access_token($args);
# set the access token on the object instance.
$args->{access_token} = $json_response->{access_token};
$args->{token_type} = $json_res
rgs->{sub})) {
$jwt_params->{sub} = $args->{sub};
}
# encode jwt.
my $jwt = JSON::WebToken::encode_jwt($jwt_params, $key_contents, JWT_ALGORITHIM, {
typ => JWT_TYP
});
$param->{ua} = $class->_new_ua;
}
unless (defined $param->{json_parser}) {
$param->{json_parser} = $class->_new_json_parser;
}
bless { %$param }, $class;
}
sub new_from_clien
equire JSON;
my $json = JSON->new->decode($content);
my ($client_type) = keys(%$json);
$class->new({
auth_uri => $json->{$client_type}->{auth_uri},
token_uri => $json->{$cl
{token_uri},
client_id => $json->{$client_type}->{client_id},
client_secret => $json->{$client_type}->{client_secret},
redirect_uri => @{$json->{$client_type}->{redirect_uris}}
/uri_escape/;
sub new {
my $class = shift;
my (%param) = @_;
for my $required (qw/ua json_parser base_url opt doc/) {
die unless $param{$required};
}
bless { %param }, $cl
(%{$self->{opt}{body}}) {
$request->content_type('application/json');
$request->content($self->{json_parser}->encode($self->{opt}{body}));
} else {
$reques
return 1;
}
return $response->header('content-type') =~ m!^application/json!
? $self->{json_parser}->decode(decode_utf8($response->content))
: $response->content