且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Perl REST客户端,身份验证问题

更新时间:2022-12-06 16:26:25

您似乎在做 HTTP基本身份验证.为此,您需要具有以下标题:

It looks like you are doing HTTP Basic authentication. For that, you need to have your header as follows:

Authorization: Basic foobar

foobarusername:password的base64表示形式.

Where foobar is the base64 representation of username:password.

在Perl中,它给出:

In Perl, that gives:

my $headers = {
  Accept => 'application/json',  
  Authorization => 'Basic ' . encode_base64($username . ':' . $password)
  #                      ^ note the space here                      
};


请注意, HTTP :: Headers还提供了一种设置HTTP基本身份验证的方法一个>.不幸的是,REST :: Client并没有直接接受它.


Note that HTTP::Headers also provides a method to set HTTP Basic authentication. Unfortunately that's not directly accepted by REST::Client.