Skip to content

Commit

Permalink
Checking in changes prior to tagging of version 0.2802.
Browse files Browse the repository at this point in the history
Changelog diff is:

diff --git a/Changes b/Changes
index c44d40b..a8f244d 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Net::Google::DataAPI

+0.2802  Mon Sep 10 12:00:00 2012
+        - Support additional params in authorize_url() (thanks to @hsw, #1)
+
 0.2801  Mon Apr 30 08:55:00 2012
         - Net::Google::DataAPI::Auth::OAuth is deprecated. (#76812)
  • Loading branch information
nobuo-danjou committed Sep 10, 2012
1 parent dd98abc commit bb1c6e0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Net::Google::DataAPI

0.2802 Mon Sep 10 12:00:00 2012
- Support additional params in authorize_url() (thanks to @hsw, https://github.com/lopnor/Net-Google-DataAPI/pull/1)

0.2801 Mon Apr 30 08:55:00 2012
- Net::Google::DataAPI::Auth::OAuth is deprecated. (#76812)

Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Google/DataAPI.pm
Expand Up @@ -5,7 +5,7 @@ use Any::Moose '::Exporter';
use Carp;
use Lingua::EN::Inflect::Number qw(to_PL);
use XML::Atom;
our $VERSION = '0.2801';
our $VERSION = '0.2802';

any_moose('::Exporter')->setup_import_methods(
as_is => ['feedurl', 'entry_has'],
Expand Down
9 changes: 8 additions & 1 deletion lib/Net/Google/DataAPI/Auth/OAuth2.pm
Expand Up @@ -5,7 +5,7 @@ with 'Net::Google::DataAPI::Role::Auth';
use Net::OAuth2::Client;
use Net::OAuth2::Profile::WebServer;
use HTTP::Request::Common;
our $VERSION = '0.01';
our $VERSION = '0.02';

has [qw(client_id client_secret)] => (is => 'ro', isa => 'Str', required => 1);
has redirect_uri => (is => 'ro', isa => 'Str', default => 'urn:ietf:wg:oauth:2.0:oob');
Expand Down Expand Up @@ -124,6 +124,13 @@ Net::Google::DataAPI::Auth::OAuth2 - OAuth2 support for Google Data APIs
);
my $url = $oauth2->authorize_url();
# you can add optional parameters:
#
# my $url = $oauth2->authorize_url(
# access_type => 'offline',
# approval_prompt => 'force',
# );
# show the user $url and get $code
# if you're making web app, you will do:
#
Expand Down
24 changes: 24 additions & 0 deletions t/04_auth/04_oauth2.t
Expand Up @@ -96,6 +96,30 @@ BEGIN {

# ok $oauth2->get_access_token('mycode');
}
{
ok my $oauth2 = Net::Google::DataAPI::Auth::OAuth2->new(
client_id => 'myclient.example.com',
client_secret => 'mysecret',
redirect_uri => 'https://example.com/callback',
scope => ['http://spreadsheets.google.com/feeds/'],
);
ok my $url = $oauth2->authorize_url(access_type => 'offline', approval_prompt => 'force');
$url = URI->new($url);
is $url->scheme, 'https';
is $url->host, 'accounts.google.com';
is $url->path, '/o/oauth2/auth';
is_deeply {$url->query_form}, {
client_id => 'myclient.example.com',
redirect_uri => 'https://example.com/callback',
response_type => 'code',
scope => 'http://spreadsheets.google.com/feeds/',
type => 'web_server',
access_type => 'offline',
approval_prompt => 'force',
} or note explain {$url->query_form};

# ok $oauth2->get_access_token('mycode');
}


done_testing;

0 comments on commit bb1c6e0

Please sign in to comment.