OAuth::Simple - Simple OAuth authorization on your site
my $oauth = OAuth::Simple->new( app_id => 'YOUR APP ID', secret => 'YOUR APP SECRET', postback => 'POSTBACK URL', ); my $url = $oauth->authorize( {url => 'https://www.facebook.com/dialog/oauth', scope => 'email', response_type => 'code'} ); # Your web app redirect method. $self->redirect($url); # Get access_token. # Facebook returns data not in JSON. Use the raw mode and parse. my $access = $oauth->request_access_token( {url => 'https://graph.facebook.com/oauth/access_token', code => $args->{code}, raw => 1} ); # Get user profile data. my $profile_data = $oauth->request_data( {url => 'https://graph.facebook.com/me', access_token => $access} );
Use this module for input VK OAuth authorization on your site
my $oauth = OAuth::Simple->new( app_id => 'YOUR APP ID', secret => 'YOUR APP SECRET', postback => 'POSTBACK URL', );
The new constructor lets you create a new OAuth::Simple object.
new
my $url = $oauth->authorize( {url => $authorize_server_url, option => 'value'} ); # Your web app redirect method. $self->redirect($url);
This method returns a URL, for which you want to redirect the user.
See information about options on your OAuth server.
Method returns URI object.
my $access = $oauth->request_access_token( {url => $server_url, code => $args->{code}} );
This method gets access token from OAuth server.
* code - returned in redirected get request from authorize API method; * raw - do not decode JSON, return raw data; * http_method - set http method: GET(default), POST, etc.
Method returns HASH object.
my $profile_data = $oauth->request( { url => $api_method_url, access_token => $access_token, raw => 1, http_method => 'POST', token_name => 'ouath_token', });
This method sends requests to OAuth server.
* url (required) - api method url; * params (not required) - other custom params on OAuth server; * access_token (required) - access token; * raw - do not decode JSON, return raw data (default 0); * http_method - set http method: GET(default), POST, etc; * token_name - access token parameter name (default 'access_token').
Method returns HASH object with requested data.
Returns HTTP::Request object.
Github: https://github.com/Foxcool/OAuth-Simple
Bugs & Issues: https://github.com/Foxcool/OAuth-Simple/issues
Alexander Babenko (foxcool@cpan.org) for Setup.ru (http://setup.ru)
sugar: Anton Ukolov (aukolov@aukolov.ru)
Copyright (c) 2012 - 2013 Alexander Babenko.
To install OAuth::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OAuth::Simple
CPAN shell
perl -MCPAN -e shell install OAuth::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.