#!/usr/bin/env perl use strict; use warnings; use 5.020; use Net::Google::DataAPI::Auth::OAuth2; use Config::General; use Term::Prompt; my $config_file = Config::General->new('google-to-text.conf'); my %config = $config_file->getall; my $oauth2 = Net::Google::DataAPI::Auth::OAuth2->new( client_id => $config{oauth2}->{client_id}, client_secret => $config{oauth2}->{client_secret}, scope => ['https://www.googleapis.com/auth/calendar.readonly'], ); my $url = $oauth2->authorize_url(); say "Go to:"; say $url; my $code = prompt('x', "then paste the code: ", '', ''); my $token = $oauth2->get_access_token($code) or die; $config{oauth2}->{token}=$token->session_freeze; $config_file->save_file('google-to-text.conf',\%config);