【发布时间】:2015-06-01 02:26:32
【问题描述】:
我在这里关注解决方案: Net::Google::AuthSub login failed with new Google Drive version
但是,在这一行:
my $token = $oauth2->get_access_token($code) or die;
我收到以下错误:
failed oauth call access token: received error: 400 Bad Request
{
"error" : "invalid_request"
}
可能是什么问题?我需要修复 Net::Google::DataAPI::Auth::OAuth2 中的内容吗? 我在 Windows 中使用 Strawberry Perl。
编辑: 以下是我的代码:
my $oauth2 = Net::Google::DataAPI::Auth::OAuth2->new(
client_id => 'XXXXXXX.apps.googleusercontent.com',
client_secret => 'XXXXXXXX',
scope => ['http://spreadsheets.google.com/feeds/'],
);
my $url = $oauth2->authorize_url();
print "OAuth URL, get code: $url\n";
use Term::Prompt;
my $code = prompt('x', 'paste the code: ', '', '');
my $token = $oauth2->get_access_token($code) or die;
【问题讨论】:
-
您是否将从网络浏览器获取的代码准确地粘贴到您的应用程序中?
-
是的,代码以 4/ 开头,以 mwI 结尾。共 77 个字符。
-
也许 Windows 在将代码复制到
code变量之前对其进行了解释。尝试将代码直接粘贴到您的应用程序中,将$code = prompt(...)行替换为$code = "... paste from browser..."。
标签: perl google-spreadsheet-api google-authentication google-oauth