【发布时间】:2014-10-23 21:08:16
【问题描述】:
我正在尝试使用 LWP::UserAgent 连接到服务器。我已经成功地在同一台服务器上使用 LWP::UserAgent 进行匿名搜索,但现在我必须“秘密”一些东西,这需要在该服务器上使用身份验证。我已经使用了代码:
my $ua = LWP::UserAgent->new;
$ua->default_header('Content-Type' => "application/x-www-form-urlencoded");
$ua->default_header('Authorization' => "Basic ".$Authent);
my $resp = $ua->post($uri);
服务器响应:错误 400,必需参数:grant_type
那么,如何使用 LWP 设置 Grand 类型参数? 我还没有找到任何关于大字体问题的页面。
我也试过了:
$ua->default_header('grant_type' => "client_credentials");
和
my $resp = $ua->post($uri, grant_type => "client_credentials");
所有三个都给出完全相同的错误消息。 我不知道如何让事情顺利进行。
【问题讨论】:
-
感谢您的快速响应。我不知道如何使用它。服务器不使用用户 ID 和密码。它使用标题上的授权来验证用户权限。这是在我的代码上给出的。问题出在 grant_type 上,必须更改。
标签: perl lwp-useragent