| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::Tumblr::Authentication::OAuth; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 16 |  |  | 16 |  | 56 | use strict; | 
|  | 16 |  |  |  |  | 19 |  | 
|  | 16 |  |  |  |  | 369 |  | 
| 4 | 16 |  |  | 16 |  | 53 | use warnings; | 
|  | 16 |  |  |  |  | 16 |  | 
|  | 16 |  |  |  |  | 338 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 16 |  |  | 16 |  | 51 | use Carp; | 
|  | 16 |  |  |  |  | 18 |  | 
|  | 16 |  |  |  |  | 1010 |  | 
| 7 | 16 |  |  | 16 |  | 83 | use Moose; | 
|  | 16 |  |  |  |  | 28 |  | 
|  | 16 |  |  |  |  | 84 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 16 |  |  | 16 |  | 70623 | use base 'WWW::Tumblr::Authentication'; | 
|  | 16 |  |  |  |  | 21 |  | 
|  | 16 |  |  |  |  | 4543 |  | 
| 10 |  |  |  |  |  |  | extends 'WWW::Tumblr'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | has 'authorize_url', is => 'rw', isa => 'Str', lazy => 1, default => sub { | 
| 13 |  |  |  |  |  |  | my $self = shift; | 
| 14 |  |  |  |  |  |  | croak "The consumer_key and secret_key must be defined!" | 
| 15 |  |  |  |  |  |  | unless $self->consumer_key && $self->secret_key; | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | return $self->oauth->authorize_url(); | 
| 18 |  |  |  |  |  |  | }; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | has 'oauth_token', is => 'rw', isa => 'Str'; | 
| 21 |  |  |  |  |  |  | has 'oauth_verifier', is => 'rw', isa => 'Str'; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | has 'token', is => 'rw', isa => 'Str', lazy => 1, default => sub{ shift->_get_token() }; | 
| 24 |  |  |  |  |  |  | has 'token_secret', is => 'rw', isa => 'Str', lazy => 1, default => sub { shift->_get_token('secret') }; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | has '_access_token', is => 'rw'; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub _get_token { | 
| 29 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 30 | 0 |  | 0 |  |  |  | my $type = shift || 'token'; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 0 | 0 | 0 |  |  |  | croak "Cannot get OAuth token without 'oauth_token' and 'oauth_verifier' defined!" | 
| 33 |  |  |  |  |  |  | unless $self->oauth_token && $self->oauth_verifier; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | warn "Session looks empty, _get_token will fall, probably" | 
| 36 | 0 | 0 |  |  |  |  | unless keys %{ $self->_session }; | 
|  | 0 |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 | 0 | 0 |  |  |  |  | $self->_access_token( $self->oauth->get_access_token( $self->oauth_token, $self->oauth_verifier ) ) | 
| 39 |  |  |  |  |  |  | unless $self->_access_token; | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 0 | 0 |  |  |  |  | return $type eq 'secret' ? $self->_access_token->token_secret : $self->_access_token->token; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | 1; |