RyanDaDeng / laravel-google-recaptcha-v3

It's probably the best Laravel Package for Google reCAPTCHA v3. Vue component supported.
MIT License
275 stars 40 forks source link

Error with vue component: gRecaptchaResponse: ["invalid-input-secret"] #79

Closed flowbru closed 3 years ago

flowbru commented 3 years ago

Hi there,

I'm trying to use the vue component in my register from.

I have added my keys to .env file RECAPTCHA_V3_SECRET_KEY=XXX RECAPTCHA_V3_SITE_KEY=XX

I have published the vue component as described in the installation docu.

I have added the rule to my RegisterUserRequest.php ` use TimeHunter\LaravelGoogleReCaptchaV3\Validations\GoogleReCaptchaV3ValidationRule; ...

public function rules() { return [ 'name' => 'required|string|max:255', 'email' => 'required|string|email|max:255|unique:users', 'password' => 'required|string|min:8|confirmed', 'gRecaptchaResponse' => ['required', new GoogleReCaptchaV3ValidationRule('sign_up')] ]; } `

I have imported and added the component to my form. ` <google-re-captcha-v3 v-model="registerForm.gRecaptchaResponse" ref="captcha" site-key="XXX" id="sign_up_id" inline action="sign_up"

.... `

And I have double checked if the sitekey and secret keys are correct.

The badge gets displayed correctly. the v-model gRecaptchaResponse has a pretty long string inside. But when I submit the form I get an error response with the message gRecaptchaResponse: ["invalid-input-secret"].

What could be the cause of that problem?

RyanDaDeng commented 3 years ago

That usually means your secret is not set correctly.

Concern 1

Please check that you are passing the full key in the right format as retrieved from https://www.google.com/recaptcha/admin#list

That error occurs, according to https://developers.google.com/recaptcha/docs/verify

The secret parameter is invalid or malformed.

Concern 2

If you are sure that secret is correct, then try to run php artisan config:clear and php artisan cache:clear to cleanup caches, sometimes env data might get cached so no secret is provided.

Can you check above things? if not, i will take a further investigation.

flowbru commented 3 years ago

Hi Ryan! Thanks for your fast response! It seems that the problem was the config cache... So thanks alot that solved my problem. And sorry for that,,,