| 1 | package OAuth::Lite::AuthMethod; | ||
| 2 | |||
| 3 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 5 | ▶ | use base 'Exporter'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 5 | ▶ | use List::MoreUtils qw(any); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 5 | our %EXPORT_TAGS = ( all => [qw/AUTH_HEADER POST_BODY URL_QUERY/] ); | |
| 11 | 5 | our @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; | |
| 12 | |||
| 13 | 5 | ▶ | use constant AUTH_HEADER => 'auth_header'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 5 | ▶ | use constant POST_BODY => 'post_body'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 5 | ▶ | use constant URL_QUERY => 'url_query'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | sub validate_method { | ||
| 18 | 12 | ▶ | my ($class, $method) = @_; |
|
Subroutine
validate_method: called CC=1 SCAR=0.0
Pod
documented
| |||
| 19 | 12 | my @methods = (AUTH_HEADER, POST_BODY, URL_QUERY); | |
| 20 | 12 | ▶ | any { $method eq $_ } @methods; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 21 | } | ||
| 22 | |||
| 23 | 5 | 1; | |
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | OAuth::Lite::AuthMethod - auth method constants. | ||
| 28 | |||
| 29 | =head1 SYNOPSIS | ||
| 30 | |||
| 31 | use OAuth::Lite::AuthMethod qw( | ||
| 32 | AUTH_HEADER | ||
| 33 | POST_BODY | ||
| 34 | URL_QUERY | ||
| 35 | ); | ||
| 36 | |||
| 37 | $consumer = OAuth::Lite::Consumer->new( | ||
| 38 | ... | ||
| 39 | auth_method => URL_QUERY, | ||
| 40 | ); | ||
| 41 | |||
| 42 | =head1 DESCRIPTION | ||
| 43 | |||
| 44 | This mere holds constants for auth method on requesting with OAuth. | ||
| 45 | |||
| 46 | =head1 CONSTANTS | ||
| 47 | |||
| 48 | =head2 AUTH_HEADER | ||
| 49 | |||
| 50 | Using Authorization header for OAuth-authentication. | ||
| 51 | |||
| 52 | Authorization: OAuth realm="http://example.org", oauth_consuemr_key="key", ... | ||
| 53 | |||
| 54 | =head2 POST_BODY | ||
| 55 | |||
| 56 | Embed OAuth authentication data into request body. | ||
| 57 | |||
| 58 | =head2 URL_QUERY | ||
| 59 | |||
| 60 | Append OAuth authentication data as query-string. | ||
| 61 | |||
| 62 | =head1 METHODS | ||
| 63 | |||
| 64 | =head2 validate_method($method) | ||
| 65 | |||
| 66 | unless ( OAuth::Lite::AuthMethod->validate_method($method) ) { | ||
| 67 | say 'Invalid auth method.'; | ||
| 68 | } | ||
| 69 | |||
| 70 | =head1 AUTHOR | ||
| 71 | |||
| 72 | Lyo Kato, C<lyo.kato _at_ gmail.com> | ||
| 73 | |||
| 74 | =head1 COPYRIGHT AND LICENSE | ||
| 75 | |||
| 76 | This library is free software; you can redistribute it and/or modify | ||
| 77 | it under the same terms as Perl itself, either Perl version 5.8.6 or, | ||
| 78 | at your option, any later version of Perl 5 you may have available. | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||