我正在尝试编写一个独立的perl应用程序,列出存储在Google Tasks中的所有任务.我被引导相信我可以使用谷歌所谓的"简单API访问",因为它只是我的任务而且它是只读的.
所以我做了以下事情:
#!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;
Run Code Online (Sandbox Code Playgroud)
作为回报,我得到:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我不知道它目前需要什么授权.我尝试用以下代码替换最后一行:
my $auth = "...";
print $browser->get($url, "Authorization", $auth)->content;
Run Code Online (Sandbox Code Playgroud)
并使用API控制台中列出的Google列出的客户端ID,电子邮件地址和客户端密码 - 但他们都给了Invalid Credentials.
有人可以帮忙吗?
似乎不起作用,他们似乎已经禁用它以支持 oauth2,并且只是没有更新 apply-for-an-api-key 页面。使用 Oauth2 代替:
https://developers.google.com/oauthplayground/
Run Code Online (Sandbox Code Playgroud)
如果您需要 api 密钥,可以在这里获取:
https://code.google.com/apis/console
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4560 次 |
| 最近记录: |