PHPackages                             oneduo/laravel-recaptcha-enterprise - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. oneduo/laravel-recaptcha-enterprise

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

oneduo/laravel-recaptcha-enterprise
===================================

This is my package laravel-recaptcha-enterprise

v0.5.0(1y ago)6083.4k—9.3%10[5 PRs](https://github.com/oneduo/laravel-recaptcha-enterprise/pulls)MITPHPPHP ^8.1CI passing

Since Jan 17Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/oneduo/laravel-recaptcha-enterprise)[ Packagist](https://packagist.org/packages/oneduo/laravel-recaptcha-enterprise)[ Docs](https://github.com/oneduo/laravel-recaptcha-enterprise)[ RSS](/packages/oneduo-laravel-recaptcha-enterprise/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (15)Used By (0)

Google reCAPTCHA Enterprise for Laravel
=======================================

[](#google-recaptcha-enterprise-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8f2e54e6ef0034c21c25e7f59a484a144dcb059fe999f08aad6ca65f4e2c5a09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6564756f2f6c61726176656c2d7265636170746368612d656e74657270726973652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-recaptcha-enterprise)[![GitHub Tests Action Status](https://camo.githubusercontent.com/e6afc6cec8ec74b1ad3bba060e2e105c96b264eeab7b41a4c4d509c928e3508e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d7265636170746368612d656e74657270726973652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-recaptcha-enterprise/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/97b3148d1d4c022b6d1ccfae5b06e49c098e715ca5366b5d60d100a0811329ee/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d7265636170746368612d656e74657270726973652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-recaptcha-enterprise/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3c6f3d3b82502c2a78676b175184434b6fc64283abad1f5d249d739ad8b3d549/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e6564756f2f6c61726176656c2d7265636170746368612d656e74657270726973652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-recaptcha-enterprise)[![codecov](https://camo.githubusercontent.com/782383e1beb11659e096c62b69888f284919052561013d7e221e2bb072a8fd90/68747470733a2f2f636f6465636f762e696f2f6769746875622f6f6e6564756f2f6c61726176656c2d7265636170746368612d656e74657270726973652f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/github/oneduo/laravel-recaptcha-enterprise)

Wrapper to use Google reCAPTCHA Enterprise with Laravel. Provides a handy validation rule to verify your token's score.

Table of Contents
-----------------

[](#table-of-contents)

- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)

Prerequisites
-------------

[](#prerequisites)

**TLDR;** You may want to follow the [official documentation](https://cloud.google.com/recaptcha-enterprise/docs/set-up-google-cloud) to get started.

### 1. Enable the reCAPTCHA Enterprise API

[](#1-enable-the-recaptcha-enterprise-api)

On your Google Cloud console, go ahead and enable the reCAPTCHA Enterprise API.

### 2. Create a service account

[](#2-create-a-service-account)

Create a service account with the following roles:

- reCAPTCHA Enterprise Agent

### 3. Create a key

[](#3-create-a-key)

Create a key for your service account and download it as a JSON file.

### 4. Use your credentials

[](#4-use-your-credentials)

Use your credentials by setting the appropriate values in `config/recaptcha-enterprise.php` or by setting the environment variables.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require oneduo/laravel-recaptcha-enterprise
```

Configuration
-------------

[](#configuration)

You can publish the config file with:

```
php artisan vendor:publish --tag="recaptcha-enterprise-config"
```

This is the contents of the published config file, you are required to set the variables accordingly:

```
return [
    'site_key' => env('RECAPTCHA_ENTERPRISE_SITE_KEY'),

    'use_credentials' => env('RECAPTCHA_ENTERPRISE_USE_CREDENTIALS', 'default'),

    'credentials' => [
        'default' => [
            'type' => 'service_account',
            'project_id' => env('RECAPTCHA_ENTERPRISE_PROJECT_ID'),
            'private_key_id' => env('RECAPTCHA_ENTERPRISE_PRIVATE_KEY_ID'),
            'private_key' => env('RECAPTCHA_ENTERPRISE_PRIVATE_KEY'),
            'client_email' => $email = env('RECAPTCHA_ENTERPRISE_CLIENT_EMAIL'),
            'client_id' => env('RECAPTCHA_ENTERPRISE_CLIENT_ID'),
            'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
            'token_uri' => 'https://accounts.google.com/o/oauth2/token',
            'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
            'client_x509_cert_url' => 'https://www.googleapis.com/robot/v1/metadata/x509/' . $email,
        ],
    ],
];
```

Usage
-----

[](#usage)

You may start using the reCAPTCHA validation rule by implementing the available `Oneduo\RecaptchaEnterprise\Rules\Recaptcha` rule in your business logic, here's an example of a `FormRequest`implementation:

```
