GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::OAuth::Client(3) User Contributed Perl Documentation Net::OAuth::Client(3)

Net::OAuth::Client - OAuth 1.0A Client

  # Web Server Example (Dancer)

  # This example is simplified for illustrative purposes, see the complete code in /demo

  # Note that client_id is the Consumer Key and client_secret is the Consumer Secret

  use Dancer;
  use Net::OAuth::Client;

  sub client {
        Net::OAuth::Client->new(
                config->{client_id},
                config->{client_secret},
                site => 'https://www.google.com/',
                request_token_path => '/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F',
                authorize_path => '/accounts/OAuthAuthorizeToken',
                access_token_path => '/accounts/OAuthGetAccessToken',
                callback => uri_for("/auth/google/callback"),
                session => \&session,
        );
  }

  # Send user to authorize with service provider
  get '/auth/google' => sub {
        redirect client->authorize_url;
  };

  # User has returned with token and verifier appended to the URL.
  get '/auth/google/callback' => sub {

        # Use the auth code to fetch the access token
        my $access_token =  client->get_access_token(params->{oauth_token}, params->{oauth_verifier});

        # Use the access token to fetch a protected resource
        my $response = $access_token->get('/m8/feeds/contacts/default/full');

        # Do something with said resource...

        if ($response->is_success) {
          return "Yay, it worked: " . $response->decoded_content;
        }
        else {
          return "Error: " . $response->status_line;
        }
  };

  dance;

Net::OAuth::Client represents an OAuth client or consumer.

WARNING: Net::OAuth::Client is alpha code. The rest of Net::OAuth is quite stable but this particular module is new, and is under-documented and under-tested.

new($client_id, $client_secret, %params)
Create a new Client
  • $client_id

    AKA Consumer Key - you get this from the service provider when you register your application.

  • $client_secret

    AKA Consumer Secret - you get this from the service provider when you register your application.

  • $params{site}
  • $params{request_token_path}
  • $params{authorize_path}
  • $params{access_token_path}
  • $params{callback}
  • $params{session}

Copyright 2011 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.

2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.