From: Ken-ichi Mito Date: Wed, 21 Aug 2013 09:59:25 +0000 (+0900) Subject: use access_token X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=4351b0ce17eb958fbc7cdd660c37c6769c9bccd9;p=lab.git use access_token * note: 'e72e16c7e42f292c6912e7710c838347ae178b4a' is a dummy * http://developer.github.com/v3/oauth/ --- diff --git a/Dev/github/GitHubBackup.pm b/Dev/github/GitHubBackup.pm index 30fd705..a059bd2 100644 --- a/Dev/github/GitHubBackup.pm +++ b/Dev/github/GitHubBackup.pm @@ -35,6 +35,9 @@ sub get { my $url = shift; my %parameters = @_; + if ($self->access_token) { + $parameters{access_token} = $self->access_token; + } my $parameters = ''; while (my($key, $value) = each %parameters) { $parameters .= "&$key=$value"; @@ -145,9 +148,10 @@ sub repos { $self->{repos} = []; my $account = $self->account or croak "account is not set"; + my $token = ($self->access_token) ? "?access_token=" . $self->access_token : ''; my $result; if (my $repository = $self->repository) { - $result = [ $self->api->json_api("/repos/$account/$repository") ]; + $result = [ $self->api->json_api("/repos/$account/$repository$token") ]; } else { $result = $self->api->get("/users/$account/repos"); diff --git a/Dev/github/github-backup.pl b/Dev/github/github-backup.pl index da6736a..aceb056 100644 --- a/Dev/github/github-backup.pl +++ b/Dev/github/github-backup.pl @@ -10,6 +10,7 @@ my $gh = GitHubBackup->new( account => 'mittyorz', repository => 'munin-plugins', directory => 'repos', + access_token => 'e72e16c7e42f292c6912e7710c838347ae178b4a', ); $gh->backup;