如何使用Perl对Gmail进行身份验证?

Che*_*eso 3 authentication perl gmail module login-script

我已安装模块以获取Gmail收件箱中的访问权限和控制权.但是,当我尝试通过一个小的Perl脚本连接并测试功能时,我收到此错误消息.

Error: Could not login with those credentials - could not find final URL
  Additionally, HTTP error: 200 OK
Run Code Online (Sandbox Code Playgroud)

这是Gmail.pm模块中内置的错误.

我可以ping有问题的网址(https://www.google.com/accounts/ServiceLoginBoxAuth),所以我觉得麻烦的是找不到网址.此外,我知道凭据是正确的,并且在该URL上工作,因为我已经手动尝试过.

我正在使用这个脚本进行测试.我已在适当的地方提供了我的凭证.


我也安装了这个模块有相同类型的错误.

知道为什么我被封锁了吗?

i-b*_*lis 12

使用Mail :: IMAPClient,如下所示.要通过Mail :: IMAPClient获得SSL身份验证,您应该安装Net :: SSLeay的IO :: Socket :: SSL.如果是这样,这就像一个魅力.

#!/usr/bin/env perl
use strict; use warnings;
use Mail::IMAPClient;

# Connect to IMAP server
my $client = Mail::IMAPClient->new(
  Server   => 'imap.gmail.com',
  User     => 'yourusername',
  Password => 'yourp4a55w0r&',
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $!";

# List folders on remote server (see if all is ok)
if ( $client->IsAuthenticated() ) {
  print "Folders:\n";
  print "- ", $_, "\n" for @{ $client->folders() };  
};

# Say so long
$client->logout();
Run Code Online (Sandbox Code Playgroud)