Captcha-reCAPTCHA-V3

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

Requires just only response key being got from Google reCAPTCHA API.

**DO NOT** add remote address. there is no function for remote address within reCAPTCHA v3.

    my $content = $rc->verify($param{$rc});

The default _query\_name_ is 'g-recaptcha-response' and it is stocked in constructor.

But now string-context provides you to get _query\_name_ so we don't have to care about it.

The response contains JSON so it returns decoded value from JSON.

    unless ( $content->{'success'} ) {
       # code for failing like below
       die 'fail to verify reCAPTCHA: ', @{ $content->{'error-codes'} }, "\n";
    }

### deny\_by\_score( response => _response_, \[ score => _expected_ \] )

reCAPTCHA v3 responses have score whether the request was by bot.

lib/Captcha/reCAPTCHA/V3.pm  view on Meta::CPAN

    } or croak "LWP::UserAgent and LWP::Protocol::https are required to verify reCAPTCHA response.";

    my $ua = LWP::UserAgent->new;
    my $res = $ua->post(
        $self->{verify_api},{
            secret   => $self->{secret},
            response => $response,
        },
    );

    my $json = $res->decoded_content;
    return decode_json($json);
}

sub deny_by_score {
    my $self     = shift;
    my %attr     = @_;
    my $response = $attr{response} || croak "missing response token";
    my $score    = $attr{score}    || 0.5;
    croak "invalid score was set: $score" if $score < 0 or 1 < $score;

lib/Captcha/reCAPTCHA/V3.pm  view on Meta::CPAN

Requires just only response key being got from Google reCAPTCHA API.

B<DO NOT> add remote address. there is no function for remote address within reCAPTCHA v3.

 my $content = $rc->verify($param{$rc});

The default I<query_name> is 'g-recaptcha-response' and it is stocked in constructor.

But now string-context provides you to get I<query_name> so we don't have to care about it.

The response contains JSON so it returns decoded value from JSON.

 unless ( $content->{'success'} ) {
    # code for failing like below
    die 'fail to verify reCAPTCHA: ', @{ $content->{'error-codes'} }, "\n";
 }

=head3 deny_by_score( response => I<response>, [ score => I<expected> ] )

reCAPTCHA v3 responses have score whether the request was by bot.



( run in 2.557 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )