From ef1dd3e51ad8e38f4a5637a4aea8b4afa6d26e3e Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 13 Nov 2015 21:12:15 +0000 Subject: script for oauth token --- get-oauth2-token | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 get-oauth2-token diff --git a/get-oauth2-token b/get-oauth2-token new file mode 100644 index 0000000..749863c --- /dev/null +++ b/get-oauth2-token @@ -0,0 +1,21 @@ +#!/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(); +my $code = prompt('x', "Go to $url, then paste the code: ", '', ''); +my $token = $oauth2->get_access_token($code) or die; +$config{oauth2}->{token}=$token; +$config_file->save('google-to-text.conf',\%config); -- cgit v1.2.3