| 1 | # Copyrights 2013-2019 by [Mark Overmeer <markov@cpan.org>]. | ||
| 2 | # For other contributors see ChangeLog. | ||
| 3 | # See the manual pages for details on the licensing terms. | ||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||
| 5 | # This code is part of distribution Net-OAuth2. Meta-POD processed | ||
| 6 | # with OODoc into POD and HTML manual-pages. See README.md | ||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||
| 8 | |||
| 9 | package Net::OAuth2::Profile::Password; | ||
| 10 | use vars '$VERSION'; | ||
| 11 | $VERSION = '0.66'; | ||
| 12 | |||
| 13 | use base 'Net::OAuth2::Profile'; | ||
| 14 | |||
| 15 | use warnings; | ||
| 16 | use strict; | ||
| 17 | |||
| 18 | use URI; | ||
| 19 | use Net::OAuth2::AccessToken; | ||
| 20 | use HTTP::Request; | ||
| 21 | |||
| 22 | |||
| 23 | sub init($) | ||
| 24 | { my ($self, $args) = @_; | ||
| 25 | $args->{grant_type} ||= 'password'; | ||
| 26 | $self->SUPER::init($args); | ||
| 27 | $self; | ||
| 28 | } | ||
| 29 | |||
| 30 | #------------------- | ||
| 31 | |||
| 32 | #-------------------- | ||
| 33 | |||
| 34 | |||
| 35 | sub get_access_token(@) | ||
| 36 | { my $self = shift; | ||
| 37 | |||
| 38 | my $request = $self->build_request | ||
| 39 | ( $self->access_token_method | ||
| 40 | , $self->access_token_url | ||
| 41 | , $self->access_token_params(@_) | ||
| 42 | ); | ||
| 43 | |||
| 44 | my $response = $self->request($request); | ||
| 45 | |||
| 46 | Net::OAuth2::AccessToken->new(client => $self | ||
| 47 | , $self->params_from_response($response, 'access token')); | ||
| 48 | } | ||
| 49 | |||
| 50 | 1; |