/examples/oauth_and_get_user_info.pl
Perl | 25 lines | 11 code | 4 blank | 10 comment | 0 complexity | 36d0850342f7f6b6339ae6f3d8d4497f MD5 | raw file
- #!/usr/bin/perl -w
- #
- # This example performs OAuth authorization sequence and then calls
- # some BitBucket method which require authorization (user details).
- # Various keys used in the process are saved in keyring (if any is
- # available).
- use strict;
- use WebService::BitBucket;
- our $QUERY_USER_URL = 'https://bitbucket.org/api/2.0/user';
- # Initiates OAuth-authorized communication, by loading access tokens
- # if they were already saved, or performing access-granting sequence
- # if not.
- my $oauth = WebService::BitBucket::OAuth->new(
- # This handles (possibly secure) storage for various secret tokens
- secret_storage => WebService::BitBucket::SecretStorageInKeyring->new(
- password_group=>"WebService::BitBucket samples",
- app_name=>"oauth_and_get_user_info"),
- browser => "firefox",
- );
- my $reply = $oauth->make_restricted_request($QUERY_USER_URL, 'GET');
- print $reply->content;