This code in Perl was working for years and now my Spreadsheets logins failed, when I logged into my account I noticed switch to a new Drive version. Probably some authentic
Thanks for this - very helpful. One addition is that the code in the original poster's answer will generate a token that expires in an hour. If you want to keep using it, you need to be sure to formulate the initial request so that it generates not only the access token, but also the refresh token. To get this, change the initial
my $url = $oauth2->authorize_url();
to
my $url = $oauth2->authorize_url(access_type => 'offline',
approval_prompt => 'force');
Then the returned token will have the necessary refresh_token included.