use Net::Google::Spreadsheets; use Net::Google::DataAPI::Auth::OAuth2; use Net::OAuth2::AccessToken; use Storable; # Authentication code based on example from gist at # https://gist.github.com/hexaddikt/6738247 # Get the token that we saved previously in order to authenticate: my $session_filename = "stored_google_access.session"; # Be sure to edit the lines below to fill in your correct client # id and client secret! my $oauth2 = Net::Google::DataAPI::Auth::OAuth2->new( client_id => '****.apps.googleusercontent.com', client_secret => '***', scope => ['http://spreadsheets.google.com/feeds/'], redirect_uri => 'https://developers.google.com/oauthplayground', ); # Deserialize the file so we can thaw the session and reuse the refresh token my $session = retrieve($session_filename); if($session->error) { print $session->error_description; } my $restored_token = Net::OAuth2::AccessToken->session_thaw($session, auto_refresh => 1, profile => $oauth2->oauth2_webserver, ); $oauth2->access_token($restored_token); # Now we can use this token to access the spreadsheets # in our account: my $service = Net::Google::Spreadsheets->new( auth => $oauth2); my $spreadsheet_by_title = $service->spreadsheet( { title => 'aaa' } );