diff options
author | dakkar <dakkar@thenautilus.net> | 2015-11-13 21:12:15 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2015-11-13 21:12:15 +0000 |
commit | ef1dd3e51ad8e38f4a5637a4aea8b4afa6d26e3e (patch) | |
tree | 453d870d1c475e266d4b6da01d6b069fdf6a7e2c | |
download | google-to-text-ef1dd3e51ad8e38f4a5637a4aea8b4afa6d26e3e.tar.gz google-to-text-ef1dd3e51ad8e38f4a5637a4aea8b4afa6d26e3e.tar.bz2 google-to-text-ef1dd3e51ad8e38f4a5637a4aea8b4afa6d26e3e.zip |
script for oauth token
-rw-r--r-- | get-oauth2-token | 21 |
1 files changed, 21 insertions, 0 deletions
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); |