From 4351b0ce17eb958fbc7cdd660c37c6769c9bccd9 Mon Sep 17 00:00:00 2001 From: Ken-ichi Mito Date: Wed, 21 Aug 2013 18:59:25 +0900 Subject: [PATCH] use access_token * note: 'e72e16c7e42f292c6912e7710c838347ae178b4a' is a dummy * http://developer.github.com/v3/oauth/ --- Dev/github/GitHubBackup.pm | 6 +++++- Dev/github/github-backup.pl | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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; -- 1.7.9.5