• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

demo/H06-Jan-2012-125110

lib/Net/H06-Jan-2012-2,022848

t/H06-Jan-2012-895707

Build.PLH A D06-Jan-20121.2 KiB4337

ChangesH A D06-Jan-20124.7 KiB10778

MANIFESTH A D06-Jan-20121.2 KiB4948

META.ymlH A D06-Jan-20122.5 KiB7978

Makefile.PLH A D06-Jan-20121.2 KiB3524

READMEH A D06-Jan-20121.8 KiB7048

README

1Net-OAuth
2
3A Perl wrapper for the OAuth 1.0 specification.
4
5http://tools.ietf.org/html/rfc5849
6
7INSTALLATION
8
9$ cpan
10cpan> install Net::OAuth
11
12WEB SERVER EXAMPLE (Dancer)
13
14  # This example is simplified for illustrative purposes, see the complete code in /demo
15
16  # Note that client_id is the Consumer Key and client_secret is the Consumer Secret
17
18  use Dancer;
19  use Net::OAuth::Client;
20
21  sub client {
22  	Net::OAuth::Client->new(
23  		config->{client_id},
24  		config->{client_secret},
25  		site => 'https://www.google.com/',
26  		request_token_path => '/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F',
27  		authorize_path => '/accounts/OAuthAuthorizeToken',
28  		access_token_path => '/accounts/OAuthGetAccessToken',
29  		callback => uri_for("/auth/google/callback"),
30  		session => \&session,
31  	);
32  }
33
34  # Send user to authorize with service provider
35  get '/auth/google' => sub {
36  	redirect client->authorize_url;
37  };
38
39  # User has returned with token and verifier appended to the URL.
40  get '/auth/google/callback' => sub {
41
42  	# Use the auth code to fetch the access token
43  	my $access_token =  client->get_access_token(params->{oauth_token}, params->{oauth_verifier});
44
45  	# Use the access token to fetch a protected resource
46  	my $response = $access_token->get('/m8/feeds/contacts/default/full');
47
48  	# Do something with said resource...
49
50  	if ($response->is_success) {
51  	  return "Yay, it worked: " . $response->decoded_content;
52  	}
53  	else {
54  	  return "Error: " . $response->status_line;
55  	}
56  };
57
58  dance;
59
60LICENSE AND COPYRIGHT
61
62Copyright (C) 2011 Keith Grennan
63
64This program is free software; you can redistribute it and/or modify it
65under the terms of either: the GNU General Public License as published
66by the Free Software Foundation; or the Artistic License.
67
68See http://dev.perl.org/licenses/ for more information.
69
70