WP::UserAgent lazyloads these, but we always need it.
use HTTP::Request::Common;
use JSON qw(encode_json decode_json);
use LWP::UserAgent;
use Module::Load qw(load);
our @CARP_NOT = map "LWP::Authen:
access_token}->to_ref;
$ref->{_class} = ref($self->{access_token});
return encode_json($ref);
}
else {
return undef;
}
}
# This does the actual saving.
sub _set_to
e_provider_headers || {};
}
my $response = $params ? $self->post($url, Content => encode_json($params), %$headers) : $self->get($url, %$headers);
if (! $response->is_success()) {
OAuth2
our $VERSION = '0.18'; our $VERSION = '0.20'; # VERSION
use strict;
use warnings;
use JSON;
our @ISA = qw(LWP::Authen::OAuth2::ServiceProvider);
sub authorization_endpoint {
return '
esponse ) = @_;
my $content = eval { decode_json( $response->content ) };
$content = $content->{ 'body' };
$response->content( encode_json( $content ) );
$self->SUPER::construct_toke
= '0.20'; # VERSION
use 5.006;
use strict;
use warnings;
use Carp qw(confess croak);
use JSON qw(decode_json);
use Memoize qw(memoize);
use Module::Load qw(load);
use URI;
our @CARP_NOT = qw(LWP::A
ntent};
if (not defined($content)) {
$content = '';
}
my $data = eval {decode_json($content)};
my $parse_error = $@;
my $token_endpoint = $self->token_endpoint();
# Ca
ne;
return <<"EOT"
Token endpoint gave invalid JSON in response.
Endpoint: $token_endpoint
Status: $status
Parse error: $parse_error
JSON:
$content
EOT
}
elsif ($data->{error}) {
<to_ref>
Construct an unblessed data structure to represent the object that can be
serialized as JSON. The default implementation just creates a shallow copy
and assumes there are no blessed subobje
OAuth2Login> for Google's
documentation.
This is not yet supported, and would require the use of JSON Web Tokens to
support.
=item Web Server Application
This is intended for applications running o
viceAccount> for
Google's documentation.
This is not yet supported, and would require the use of JSON Web Tokens to
support.
=back
=head1 AUTHORS
=over 4
=item *
Ben Tilly, <btilly at gmail.com>
rl_base.'oauth/verify' => { access_token => $access_token_str });
my $content = eval { decode_json($res->content) };
my $scope = $content->{scope};
my $client_id = $content->{client_
ERSION
use strict;
use warnings;
use base qw/LWP::Authen::OAuth2::ServiceProvider/;
use JSON qw/decode_json/;
sub authorization_endpoint {
my $self = shift;
my $host = $self->{use_test_url
_headers {
return { 'Content-Type' => 'application/vnd.dwolla.v1.hal+json', 'Accept' => 'application/vnd.dwolla.v1.hal+json' };
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
LWP::Authen::OA
r> can also require you to authenticate
in any further way that they please. You will get back a JSON response.
An example request might look like this:
POST /o/oauth2/token HTTP/1.1
Host:
onse if you're lucky will look something like:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"access_token":"1
}
or if you're unlucky, maybe like this:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
{
"error":"invalid_