Google-OAuth
view release on metacpan or search on metacpan
lib/Google/OAuth/Install.pm view on Meta::CPAN
eof
my %client = Google::OAuth::Config->setclient ;
$client{dsn}->loadschema unless &testdb ;
return print STDERR <<'eof' unless &testdb ;
Unable to open database dsn
eof
Google::OAuth->setclient ;
my @ok = Google::OAuth->token_list ;
return print join( "\n ", "Successfully found tokens:", @ok ), "\n"
if @ok ;
my $response = Google::OAuth->grant_code( $code ) ;
return 0 & printf "Token successfully generated for %s\n",
$response->{emailkey} if $response->{emailkey} ;
print "Unknown Error. Here's what Google has to say:\n" ;
print ref $response? join( "\n ", '', %$response ): " $response" ;
return print "\n" ;
}
sub install {
return unless my $ok = init('install') ;
Google::OAuth->setclient ;
return if Google::OAuth->token_list == 0 && test( 1 ) ;
copy( $ok, $INC{'Google/OAuth/Config.pm'} ) ;
printf "Updated %s\n", $INC{'Google/OAuth/Config.pm'} ;
}
$config = <<'eof' ;
package Google::OAuth::Config ;
my %client ;
our %test ;
###############################################################################
# #
# Step 1 - Specify a NoSQL::PL2SQL database driver #
# #
# NoSQL::PL2SQL is ideal for the amorphous data structures used in #
# Google API's and other web services. In order to use NoSQL::PL2SQL, #
# you must install one of the NoSQL::PL2SQL::DBI drivers appropriate for #
# your installation. Specify the driver below. #
# #
# The only driver currently available is NoSQL::PL2SQL::DBI::MySQL. Please #
# contact jim@tqis.com for information about other drivers. #
# #
###############################################################################
## Step 1 - Specify a NoSQL::PL2SQL database driver
# use NoSQL::PL2SQL::DBI::MySQL ; ## Uncomment
###############################################################################
# #
# Step 2 - Specify Google API credentials #
# #
# If you haven't already, you must register an application to access the #
# Google API. Here is the link to register: #
# https://code.google.com/apis/console/ #
# #
# Once you've registered, the values required below can be displayed by #
# clicking the "API Access" tab in the upper left navigation. #
# #
# Warning: The client_secret and dsn access will be available to #
# everyone in a shared environment. Refer to "SECURE INSTALLATION"
# in the manual. #
# #
###############################################################################
## Step 2 - Specify Google API credentials
$client{redirect_uri} = '' ;
$client{client_id} = '' ;
$client{client_secret} = '' ; ## May be left blank
###############################################################################
# #
# Step 3 - Define the NoSQL::PLSQL dsn #
# #
# A NoSQL:PL2SQL data source (DSN) is defined as a single table. Perldoc #
# NoSQL::PL2SQL:DBI: #
# http://search.cpan.org/~tqisjim/NoSQL-PL2SQL-1.20/lib/NoSQL/PL2SQL/DBI.pm #
# #
# The table will be built as part of this installation process. #
# #
###############################################################################
## Step 3 - Define the NoSQL::PLSQL dsn
## Refer to "SECURE INSTALLATION" before connecting the database
# $client{dsn} = NoSQL::PL2SQL::DBI::MySQL->new( $tablename ) ;
# $client{dsn}->connect( 'DBI:mysql:'.$dbname, @login ) ;
###############################################################################
# #
# Step 4 - Acquire a Grant Code #
# #
# Before proceeding, you may test your settings as follows: #
# perl -MGoogle::OAuth::Install settings configfile #
# #
# In order to test your settings, you'll need to acquire a "Grant Code" #
# from Google using a web browser. The link is dynamically generated #
# using Google::OAuth. The easiest way to access this link is by email #
# as follows: #
# #
# perl -MGoogle::OAuth::Install grantcode configfile | mail you@yours.com #
# #
# This process is effectively the same as what your users will experience. #
# #
# 1. Use the Google::OAuth library to generate a link #
# 2. The link will prompt users to log in and authorize your app #
# 3. After authorization, the user is redirected to your specified #
# redirect_uri #
# 4. Google will append a grant code to your url as a query_string #
# argument. #
# #
# You'll need to capture the grant code and enter it below: #
# #
###############################################################################
## Step 4 - Acquire a Grant Code
$test{grantcode} = '' ;
###############################################################################
# #
# Step 5 - Test your configuration #
( run in 0.496 second using v1.01-cache-2.11-cpan-39bf76dae61 )