Net :: Google :: DataAPI :: Auth :: OAuth2 oauth呼叫访问令牌失败:收到错误:400 Bad Request

时间:2015-06-01 02:26:32

标签: perl google-spreadsheet-api google-authentication google-oauth2

我在这里关注解决方案: 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;

1 个答案:

答案 0 :(得分:0)

当我这样做时,我总是得到以4开头的代码并以mwI#结束。也许你错过了最后一个#字符?