summaryrefslogtreecommitdiff
path: root/get-oauth2-token
blob: 5db32d3559cfe16588c55702ad404f3905a58924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/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($codeor die;
$config{oauth2}->{token}=$token->session_freeze;
$config_file->save_file('google-to-text.conf',\%config);