Pcore
view release on metacpan or search on metacpan
lib/Pcore/API/Google/OAuth.pm view on Meta::CPAN
has _openssl_rsa => ( init_arg => undef );
const our $JWT_HEADER => to_b64u to_json {
alg => 'RS256',
typ => 'JWT',
};
sub BUILD ( $self, $args ) {
$self->{key} = P->cfg->read( $self->{key} ) if !is_ref $self->{key};
$self->{_openssl_rsa} = Crypt::OpenSSL::RSA->new_private_key( $self->{key}->{private_key} );
$self->{_openssl_rsa}->use_sha256_hash;
return;
}
# https://developers.google.com/identity/protocols/OAuth2ServiceAccount#authorizingrequests
sub get_token ( $self ) {
my $token = $self->{_token};
lib/Pcore/API/majestic.pm view on Meta::CPAN
package Pcore::API::majestic;
use Pcore -class, -res;
use Pcore::Util::Scalar qw[is_plain_arrayref];
use Pcore::Util::Data qw[to_uri from_json];
use Pcore::HTTP qw[$UA_CHROME_WINDOWS];
has api_key => (); # direct access to the API, access is restricted by IP address
has openapp_access_token => (); # OpenApp access, user key, identify user
has openapp_private_key => (); # OpenApp access, application vendor key, identify application
# required for bulk_backlink_check
has username => ();
has password => ();
has twocaptchs => ();
has max_threads => 3;
has proxy => ();
has _semaphore => sub ($self) { Coro::Semaphore->new( $self->{max_threads} ) }, is => 'lazy';
lib/Pcore/API/majestic.pm view on Meta::CPAN
# }
sub _req ( $self, $params ) {
my $guard = $self->{max_threads} && $self->_semaphore->guard;
my $url = 'https://api.majestic.com/api/json?';
if ( $self->{api_key} ) {
$url .= "app_api_key=$self->{api_key}&";
}
elsif ( $self->{openapp_private_key} && $self->{openapp_access_token} ) {
$url .= "accesstoken=$self->{openapp_access_token}&privatekey=$self->{openapp_private_key}&";
}
$url .= to_uri $params;
my $res = P->http->get( $url, proxy => $self->{proxy} );
if ($res) {
my $data = eval { from_json $res->{data} };
if ($@) {
( run in 0.243 second using v1.01-cache-2.11-cpan-4d50c553e7e )