e OAuth::Lite2::Formatter::JSON;
use strict;
use warnings;
use parent 'OAuth::Lite2::Formatter';
use JSON;
use Try::Tiny;
sub name { "json" }
sub type { "application/json" };
sub format {
my
@_;
return JSON->new->encode($hash);
}
sub parse {
my ($self, $json) = @_;
return JSON->new->decode($json);
}
=head1 NAME
OAuth::Lite2::Formatter::JSON - OAuth 2.0 JSON formatters stor
matter = OAuth::Lite2::Formatter::JSON->new;
my $obj = $formatter->parse( $string );
$string = $formatter->format( $obj );
=head1 DESCRIPTION
OAuth 2.0 JSON formatter
=head1 METHODS
=head2
est) = @_;
# from draft-v8, format is specified to JSON only.
my $format = "json";
# my $format = $request->param("format") || "json";
my $formatter = OAuth::Lite2::Formatters->get_fo
rmatter_by_name($format)
|| OAuth::Lite2::Formatters->get_formatter_by_name("json");
my $res = try {
my $type = $request->param("grant_type")
or OAuth::Lite2::Server:
se( $formatted_string );
=head1 SEE ALSO
L<OAuth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::XML>
L<OAuth::Lite2::Formatter::FormURLEncoded>
=head1 AUTHOR
Lyo K
nt(
join "/", __PACKAGE__, $OAuth::Lite2::VERSION);
}
# $self->{format} ||= 'json';
$self->{response_parser} = OAuth::Lite2::Client::TokenResponseParser->new;
return $sel
nt(
join "/", __PACKAGE__, $OAuth::Lite2::VERSION);
}
# $self->{format} ||= 'json';
$self->{response_parser} = OAuth::Lite2::Client::TokenResponseParser->new;
return $sel
gent(
join "/", __PACKAGE__, $OAuth::Lite2::VERSION);
}
$self->{format} ||= 'json';
$self->{response_parser} = OAuth::Lite2::Client::TokenResponseParser->new;
return $sel
head1 SEE ALSO
L<OAuth::Lite2::Formatter>
L<OAuth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::FormURLEncoded>
=head1 AUTHOR
Lyo Kato, E<lt>lyo.kato@gmail.comE<gt
head1 SEE ALSO
L<OAuth::Lite2::Formatter>
L<OAuth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::XML>
=head1 AUTHOR
Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
=head1 C
Auth::Lite2::Formatters>
L<OAuth::Lite2::Formatter::FormURLEncoded.pm>
L<OAuth::Lite2::Formatter::JSON>
L<OAuth::Lite2::Formatter::XML>
=head1 AUTHOR
Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
=head1 C
package OAuth::Lite2::Formatters;
use strict;
use warnings;
use OAuth::Lite2::Formatter::JSON;
use OAuth::Lite2::Formatter::XML;
use OAuth::Lite2::Formatter::FormURLEncoded;
use OAuth::Lite2::Format
S_BY_TYPE{$formatter->type} = $formatter;
}
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::JSON->new );
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::XML->new );
__PACKAGE__->add_formatt
ter = OAuth::Lite2::Formatter->get_formatter_by_name("json");
my $formatter = OAuth::Lite2::Formatter->get_formatter_by_type("application/json");
my $obj = $formatter->parse( $string );
$