I'm trying write a standalone perl app that list all my tasks stored in Google Tasks. I'm led to believe I can use what Google call "Simple API Access" because it's just my tasks and it's read only.
So I did the following:
#!perl
use LWP;
my $browser = LWP::UserAgent->new;
my $list = "Iyrhxu8sRTVOhE4hUBr4W1kwNTI6MDow";
my $key = "<api key removed>";
my $url = "https://www.googleapis.com/tasks/v1/lists/$list/tasks?pp=1&key=$key";
print $browser->get($url)->content;
In return, I get:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Unfortunately I've no idea what authorization it wants at this point. I tried replacing the last line with:
my $auth = "...";
print $browser->get($url, "Authorization", $auth)->content;
and using the Google listed Client ID, Email address and Client Secret listed in the API Console - but they all gave Invalid Credentials
.
Can anyone help?
Common API Authentication Methods The simplest way to handle authentication is through the use of HTTP, where the username and password are sent alongside every API call. You can use an HTTP header and encode the username and password.
Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key.
You can pass in the API Key to our APIs either by using the HTTP Basic authentication header or by sending an api_key parameter via the query string or request body. If you use our client library CARTO. js, you only need to follow the authorization section and we will handle API Keys automatically for you.
Doesn't seem to work, they seem to have disabled it in favor of oauth2, and just haven't updated the apply-for-an-api-key page. Use Oauth2 instead:
https://developers.google.com/oauthplayground/
If you need an api key, you can get it here:
https://code.google.com/apis/console
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With