File: Request.pm

package info (click to toggle)
libnet-oauth-perl 0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 308 kB
  • sloc: perl: 1,484; makefile: 8
file content (105 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package Net::OAuth::Request;
use warnings;
use strict;
use base qw/Net::OAuth::Message/;
use URI;
use URI::QueryParam;

use Net::OAuth;
our $VERSION = '0.31';

__PACKAGE__->mk_classdata(required_message_params => [qw/
    consumer_key
    signature_method
    timestamp
    nonce
    /]);

__PACKAGE__->mk_classdata(optional_message_params => [qw/
    version
    signature
    /]);

__PACKAGE__->mk_classdata(required_api_params => [qw/
    request_method
    request_url
    consumer_secret
    /]);

__PACKAGE__->mk_classdata(optional_api_params => [qw/
    signature_key
    token_secret
    extra_params
    protocol_version
    /]);

__PACKAGE__->mk_classdata(signature_elements => [qw/
    request_method
    normalized_request_url
    normalized_message_parameters
    /]);

__PACKAGE__->mk_classdata(all_message_params => [
    @{__PACKAGE__->required_message_params},
    @{__PACKAGE__->optional_message_params},
	]);

__PACKAGE__->mk_classdata(all_api_params => [
    @{__PACKAGE__->required_api_params},
    @{__PACKAGE__->optional_api_params},
	]);

__PACKAGE__->mk_classdata(all_params => [
    @{__PACKAGE__->all_api_params},
    @{__PACKAGE__->all_message_params},
	]);

__PACKAGE__->mk_accessors(
    @{__PACKAGE__->all_params},
    );

sub signature_key {
    my $self = shift;
    # For some sig methods (I.e. RSA), users will pass in their own key
    my $key = $self->get('signature_key');
    unless (defined $key) {
        $key = Net::OAuth::Message::encode($self->consumer_secret) . '&';
        $key .= Net::OAuth::Message::encode($self->token_secret) if $self->can('token_secret');
    }
    return $key;
}

sub normalized_request_url {
    my $self = shift;
    my $url = $self->request_url;
    Net::OAuth::Message::_ensure_uri_object($url);
    $url = $url->clone;
    $url->query(undef);
    return $url;
}


=head1 NAME

Net::OAuth::Request - base class for OAuth requests

=head1 SEE ALSO

L<Net::OAuth>, L<http://oauth.net>

=head1 AUTHOR

Originally by Keith Grennan <kgrennan@cpan.org>

Currently maintained by Robert Rothenberg <rrwo@cpan.org>

=head1 COPYRIGHT & LICENSE

Copyright 2007-2012, 2024-2025 Keith Grennan

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;