PageRenderTime 53ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/oauth_and_get_user_info.pl

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