I'm trying to access the github API from Perl.
I tried two modules, Pithub and Net::GitHub::V3. In both cases I could access public data, but the only response I got was endless "Not Found" or "Authentication Required" when I tried to authenticate. In the case of Net::GitHub::V3, I tried both the token and the login/pass methods of logging in, but all I got was "Authentication Required".
The NGV script looks like this:
use Net::GitHub::V3;
my $gh = Net::GitHub::V3->new (
login => '####',
pass => '%%%%',
);
my $repos = $gh->repos;
my $rp = $gh->repos->create ({
name => 'hello-world',
description => 'monkey business',
homepage => 'www.exmpale.org',
});
The documentation doesn't make it clear what else is required.
For Pithub, I tried to use the token method, but that also failed.
use FindBin '$Bin';
use Pithub;
use Data::Dumper;
use File::Slurper 'read_text';
my $token = read_text ("$Bin/token");
$token =~ s/\s//g;
my $pid = Pithub->new (
user => '####',
repo => '%%%%',
token => $token,
);
my $result = $pid->repos->get ();
print Dumper $result;
Does anyone have a short working example of accessing github using either of these, or alternatively is there another module which has a documented example of how to log in?
Update I found App::ph on CPAN, but this is failing with the "Not Found" error when I type in my name and password.
$ ph
setup ph. please input your id/pw to this prompt. password will not sa
+ve to any location.
user: %%%%
pass: ####
Use of uninitialized value in pattern match (m//) at /home/ben/softwar
+e/install/bin/ph line 362.
HTTP/1.1 404 Not Found
Connection: close
Date: Mon, 22 Feb 2021 01:32:35 GMT
Server: GitHub.com
Vary: Accept-Encoding, Accept, X-Requested-With
Content-Length: 74
Content-Type: application/json; charset=utf-8
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-Gi
+tHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used,
+ X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-I
+nterval, X-GitHub-Media-Type, Deprecation, Sunset
Client-Date: Mon, 22 Feb 2021 01:32:35 GMT
Client-Peer: 52.69.239.207:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=Di
+giCert SHA2 High Assurance Server CA
Client-SSL-Cert-Subject: /C=US/ST=California/L=San Francisco/O=GitHub,
+ Inc./CN=*.github.com
Client-SSL-Cipher: TLS_AES_128_GCM_SHA256
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Version: TLSv1_3
Content-Security-Policy: default-src 'none'
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-or
+igin
Strict-Transport-Security: max-age=31536000; includeSubdomains; preloa
+d
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-GitHub-Media-Type: github.v3; format=json
X-GitHub-Request-Id: EE38:0A8D:5C048:694DB:603309B3
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1613961155
X-Ratelimit-Used: 1
X-XSS-Protection: 1; mode=block
{"message":"Not Found","documentation_url":"https://docs.github.com/re
+st"}
$
This endless "Not Found" is rather frustrating.