Net-OAuth

OAuth 1.0 for Perl, implementing RFC 5849.

http://tools.ietf.org/html/rfc5849

INSTALLATION

  $ cpanm Net::OAuth

USAGE

Net::OAuth::Client is the high-level API. It is framework-agnostic: supply
your own redirect and session handling.

  use Net::OAuth::Client;

  my $client = Net::OAuth::Client->new(
      $consumer_key,
      $consumer_secret,
      site               => 'https://provider.example/',
      request_token_path => '/oauth/request_token',
      authorize_path     => '/oauth/authorize',
      access_token_path  => '/oauth/access_token',
      callback           => 'https://you.example/auth/callback',
      session            => \&session,
  );

  # 1. Send the user to the provider to authorize.
  #    (use whatever your framework provides to redirect)
  $client->authorize_url;

  # 2. They return to your callback with oauth_token and oauth_verifier.
  my $access_token = $client->get_access_token($token, $verifier);

  # 3. Use the access token to fetch a protected resource.
  my $response = $access_token->get('/profile');
  die $response->status_line unless $response->is_success;
  print $response->decoded_content;

The session argument is a coderef used to stash the request token secret
between steps 1 and 2; called with a key it reads, with a key and value it
writes.

Net::OAuth itself is the low-level interface for reading and writing OAuth
messages directly.

  perldoc Net::OAuth
  perldoc Net::OAuth::Client

AUTHOR

Originally by Keith Grennan <foss@nearlyfree.org>

Currently maintained by Robert Rothenberg <perl@rhizomnic.com>

LICENSE AND COPYRIGHT

Copyright 2007-2012, 2024-2025 Keith Grennan

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.
