summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Klausner <domm@plix.at>2019-02-25 21:28:24 +0100
committerGitHub <noreply@github.com>2019-02-25 21:28:24 +0100
commit4ebc519c12b79e2067efc5473158708c3d34086a (patch)
tree38fa16f80759b17684c830bf7818bd8c9674059e
parenta587712a0818c0a48806f4b44e7fd7cb0a56d727 (diff)
parent619b2c1f343e3b6a6ce7c146671e18c149646324 (diff)
Merge pull request #10 from michael-stevens/master
A bit of cleanup and a Yahoo ServiceProvider
-rw-r--r--.gitignore1
-rw-r--r--MANIFEST2
-rw-r--r--Makefile.PL1
-rw-r--r--lib/LWP/Authen/OAuth2.pm8
-rw-r--r--lib/LWP/Authen/OAuth2/ServiceProvider.pm2
-rw-r--r--lib/LWP/Authen/OAuth2/ServiceProvider/Yahoo.pm116
-rw-r--r--t/LWP/Authen/OAuth2/ServiceProvider/Yahoo.t23
7 files changed, 152 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 5e0d876..cbcaad8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ pm_to_blib
LWP-Authen-OAuth2-*
LWP-Authen-OAuth2-*.tar.gz
*.swp
+*~ \ No newline at end of file
diff --git a/MANIFEST b/MANIFEST
index ac84981..8cf66c6 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -11,6 +11,7 @@ lib/LWP/Authen/OAuth2/ServiceProvider/Google.pm
lib/LWP/Authen/OAuth2/ServiceProvider/Line.pm
lib/LWP/Authen/OAuth2/ServiceProvider/Line/AccessToken.pm
lib/LWP/Authen/OAuth2/ServiceProvider/Strava.pm
+lib/LWP/Authen/OAuth2/ServiceProvider/Yahoo.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
@@ -26,6 +27,7 @@ t/LWP/Authen/OAuth2/ServiceProvider/Google.t
t/LWP/Authen/OAuth2/ServiceProvider/Line.t
t/LWP/Authen/OAuth2/ServiceProvider/Line/AccessToken.t
t/LWP/Authen/OAuth2/ServiceProvider/Strava.t
+t/LWP/Authen/OAuth2/ServiceProvider/Yahoo.t
t/manifest.t
t/pod.t
LICENSE
diff --git a/Makefile.PL b/Makefile.PL
index e91df62..851d96f 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -26,6 +26,7 @@ WriteMakefile(
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'LWP-Authen-OAuth2-*' },
+ test => { TESTS => "t/*.t t/LWP/Authen/*.t t/LWP/Authen/OAuth2/*.t t/LWP/Authen/OAuth2/ServiceProvider/*.t t/LWP/Authen/OAuth2/ServiceProvider/Line/*.t t/LWP/Authen/OAuth2/AccessToken/*.t" },
(eval { ExtUtils::MakeMaker->VERSION(6.46) } ? (META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
diff --git a/lib/LWP/Authen/OAuth2.pm b/lib/LWP/Authen/OAuth2.pm
index 0560cbe..b7c9141 100644
--- a/lib/LWP/Authen/OAuth2.pm
+++ b/lib/LWP/Authen/OAuth2.pm
@@ -385,6 +385,12 @@ L<LWP::Authen::OAuth2::ServiceProvider::Strava>
implemented by L<Leon Wright|https://github.com/techman83>
+=item * Yahoo
+
+L<LWP::Authen::OAuth2::ServiceProvider::Yahoo>
+
+implemented by L<Michael Stevens|https://github.com/michael-stevens>
+
=back
You can also access any other OAuth2 service by setting up a plain C<LWP::Authen::OAuth2> object. If you do, and the service provider might be of interest to other people, please submit a patch so we can include it in this distribution, or release it as a standalone package.
@@ -832,7 +838,7 @@ You can also look for information at:
=item Github (submit patches here)
-L<https://github.com/btilly/perl-oauth2>
+L<https://github.com/domm/perl-oauth2>
=item RT: CPAN's request tracker (report bugs here)
diff --git a/lib/LWP/Authen/OAuth2/ServiceProvider.pm b/lib/LWP/Authen/OAuth2/ServiceProvider.pm
index 2bca13c..25e3c1c 100644
--- a/lib/LWP/Authen/OAuth2/ServiceProvider.pm
+++ b/lib/LWP/Authen/OAuth2/ServiceProvider.pm
@@ -472,6 +472,8 @@ hopefully useful configuration and documentation:
=item L<LWP::Authen::OAuth2::ServiceProvider::Strava|Strava>
+=item L<LWP::Authen::OAuth2::ServiceProvider::Yahoo|Yahoo>
+
=back
=head1 SUBCLASSING
diff --git a/lib/LWP/Authen/OAuth2/ServiceProvider/Yahoo.pm b/lib/LWP/Authen/OAuth2/ServiceProvider/Yahoo.pm
new file mode 100644
index 0000000..bf98f89
--- /dev/null
+++ b/lib/LWP/Authen/OAuth2/ServiceProvider/Yahoo.pm
@@ -0,0 +1,116 @@
+package LWP::Authen::OAuth2::ServiceProvider::Yahoo;
+
+our @ISA = qw(LWP::Authen::OAuth2::ServiceProvider);
+our $VERSION = "0.01";
+
+sub authorization_endpoint {
+ return "https://api.login.yahoo.com/oauth2/request_auth";
+}
+
+sub token_endpoint {
+ return "https://api.login.yahoo.com/oauth2/get_token";
+}
+
+sub authorization_required_params {
+ my $self = shift;
+ return ("client_id", "redirect_uri", "response_type", $self->SUPER::authorization_required_params());
+}
+
+sub authorization_optional_params {
+ my $self = shift;
+ return ("state", "language", $self->SUPER::authorization_optional_params());
+}
+
+sub refresh_required_params {
+ my $self = shift;
+ return ("client_id", "client_secret", "redirect_uri", "grant_type", $self->SUPER::refresh_required_params());
+}
+
+sub request_required_params {
+ my $self = shift;
+ return ("client_id", "client_secret", "redirect_uri", "grant_type", $self->SUPER::request_required_params());
+}
+
+sub authorization_default_params {
+ my $self = shift;
+ return ("response_type" => "code", $self->SUPER::authorization_default_params());
+}
+
+sub request_default_params {
+ my $self = shift;
+ return ("grant_type" => "authorization_code", $self->SUPER::request_default_params());
+}
+
+sub refresh_default_params {
+ my $self = shift;
+ return ("grant_type" => "refresh_token", $self->SUPER::refresh_default_params());
+}
+
+1;
+
+=head1 NAME
+
+LWP::Authen::OAuth2::ServiceProvider::Yahoo - Access Yahoo API OAuth2 APIs
+
+=head1 VERSION
+
+Version 0.01
+
+=head1 SYNOPSIS
+
+See L<https://developer.yahoo.com/oauth2/guide/"> for Yahoo's own documentation.
+
+=head1 REGISTERING
+
+Before you can use OAuth 2 with Yahoo you need to register yourself as an app. For that, go to L<https://developer.yahoo.com/apps/create/>.
+
+=head1 AUTHOR
+
+Michael Stevens, C<< <mstevens@etla.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-lwp-authen-oauth2 at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LWP-Authen-OAuth2>.
+
+=head1 SUPPORT
+
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc LWP::Authen::OAuth2::ServiceProvider
+
+You can also look for information at:
+
+=over 4
+
+=item Github (submit patches here)
+
+L<https://github.com/domm/perl-oauth2>
+=
+item RT: CPAN's request tracker (report bugs here)
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=LWP-Authen-OAuth2>
+
+=item AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/LWP-Authen-OAuth2>
+
+=item CPAN Ratings
+
+L<http://cpanratings.perl.org/d/LWP-Authen-OAuth2>
+
+=item Search CPAN
+
+L<http://search.cpan.org/dist/LWP-Authen-OAuth2/>
+
+=back
+
+http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LWP-Authen-OAuth2
+
+=head1 LICENSE AND COPYRIGHT
+
+This software is copyright (c) 2018 by Michael Stevens.
+
+This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
+
+=cut
diff --git a/t/LWP/Authen/OAuth2/ServiceProvider/Yahoo.t b/t/LWP/Authen/OAuth2/ServiceProvider/Yahoo.t
new file mode 100644
index 0000000..68405af
--- /dev/null
+++ b/t/LWP/Authen/OAuth2/ServiceProvider/Yahoo.t
@@ -0,0 +1,23 @@
+#! /usr/bin/env perl
+use 5.006;
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+
+use FindBin qw($Bin);
+use lib "$Bin/../../../../../lib";
+
+BEGIN {
+ use_ok("LWP::Authen::OAuth2::ServiceProvider::Yahoo") || print "Bail out!\n";
+ use LWP::Authen::OAuth2;
+
+ my $oauth2 = LWP::Authen::OAuth2->new(
+ client_id => "test",
+ client_secret => "test",
+ service_provider => "Yahoo",
+ redirect_url => "oob",
+ );
+ isa_ok($oauth2, "LWP::Authen::OAuth2");
+}
+
+done_testing();