这段代码为
帖子网址为https://accounts.google.com/o/oauth2/token
范围是“https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.google.com/m8/feeds/”
授权类型为授权代码
代码来自谷歌
我的 %args = (
client_id => $config->{client_id},
client_secret => $config->{client_secret},
redirect_uri => $config->{redirect_uri},
范围 => $config->{范围},
grant_type => $config->{grant_type},
代码 => $代码,
);
我的 $ua = LWP::UserAgent->new;
我的 $ua_response = $ua->post( $uri, \%args );
我得到的是如下所示:(响应是 html 转义)
$VAR1 = \祝福({
'_content' => '<HTML> <HEAD> <TITLE>错误处理 OAuth 2 请求</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>错误处理 OAuth 2请求</H1> <H2>错误500</H2> </BODY> </HTML>',
1990 年 1 月 1 日 00:00:00 GMT', 'pragma' => 'no-cache', 'server' => 'GSE', 'title' => 'Error processing OAuth 2 request', 'x-content-type -options' => 'nosniff', 'x-frame-options' => 'SAMEORIGIN', 'x-xss-protection' => '1; 模式=块' }, 'HTTP::Headers' ),
'_msg' => '处理 OAuth 2 请求时出错',
'_protocol' => 'HTTP/1.1',
'_rc' => '500',
'_request' => bless( { '_content' => 'grant_type=authorization_code&redirect_uri=http%3A%2F%2Fwww.xxx.com%2Foauth%2Fcallback%2Fgoogle&client_secret=xxx&client_id=xxx.apps.googleusercontent.com&code=4%2FSihUM4Zw1OPiWLMi- gdGvKOfiY4M.cggfQHKT31QagrKXntQAax3e4-qpbgI&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww。 google.com%2Fm8%2Ffeeds%2F',
'_headers' => bless( { 'content-length' => 424, 'content-type' => 'application/x-www-form-urlencoded', 'user-agent' => 'libwww-perl/6.04' }, 'HTTP::Headers' ),
'_method' => 'POST',
'_uri' => bless(do{\(my $o = 'https://accounts.google.com/o/oauth2/token')}, 'URI::https' ),
'_uri_canonical' => ${$VAR1}->{'_request'}->{'_uri'} },
'HTTP::Request' ) }, 'HTTP::Response' );
实际上它有时会起作用,但并非适用于所有情况。
有什么问题吗?