Skip to content

Instantly share code, notes, and snippets.

@utaani
Created September 2, 2013 02:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utaani/6408664 to your computer and use it in GitHub Desktop.
Save utaani/6408664 to your computer and use it in GitHub Desktop.
get_cybozulive_access_taken.pl : サイボウズLive! にAPIでアクセスするのに必要なアクセストークンをxAuthで取得する。 OAuth::Lite::Consumer http://search.cpan.org/~lyokato/OAuth-Lite-1.31/ を使う。 Developer Center https://developer.cybozulive.com/ でデベロッパー登録した上で、アプリケーション登録をして Consumer Key/Consumer Secretを取得する。 SSLをProxy経由で用いるため、Net::SSLを使うように上書きする。 参考: https://developer.cybozulive.com/…
#!/usr/bin/perl
use OAuth::Lite::Consumer;
use Data::Dumper;
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{HTTPS_PROXY} = 'http://192.168.11.254:8080';
my $consumer = OAuth::Lite::Consumer->new(
# you have to get your keys from Developer Center
# https://developer.cybozulive.com/
consumer_key => '908830ad3b5ab839682dd6a667939ece9ece60',
consumer_secret => '1ff82e592c3179701757883669871ebce9b8d75',
);
my $res = $consumer->obtain_access_token(
url => q{https://api.cybozulive.com/oauth/token},
params => {
x_auth_username => 'sample@example.com',
x_auth_password => 'examplepassword',
x_auth_mode => "client_auth",
},
);
unless($res) {
print "Failed to get access token";
die CORE::dump($consumer->oauth_response);
}
print "TOKEN:".$res->token->token."\n";
print "TOKEN-SECRET:".$res->token->secret."\n";
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment