Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recaptcha Verify() method returns invalid-input-secret #237

Closed
engharb opened this issue Jun 11, 2018 · 8 comments
Closed

recaptcha Verify() method returns invalid-input-secret #237

engharb opened this issue Jun 11, 2018 · 8 comments
Labels

Comments

@engharb
Copy link

engharb commented Jun 11, 2018

Hello,

I am starting using this lib, and when I submit my form and verify the secret I got always 'invalid-input-secret' ?

Do you have any idea?

@rowan-m
Copy link
Contributor

rowan-m commented Jul 31, 2018

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.

@rowan-m rowan-m closed this as completed Aug 1, 2018
@don-odyssey
Copy link

I have the same problem and have never gotten this to work. I pass the correct key but no success.

@maxight
Copy link

maxight commented Dec 30, 2019

I encountered the same error and was able to resolve it.
The thing is that you should use two different secret keys, one on the client-side, and another one (not the same) on the server-side.

When you open secret keys in google page (https://www.google.com/recaptcha/admin/site/XXXXXXXXX/setup), then you'll see two keys: first one is for client-side, the second one is for Verify() method on the server-side.

@gigil-mindcoopers
Copy link

Same for me even using different key one for client side(site key) and other for server verification(secret key). Still I'm getting the error code ['invalid-input-secret']

@faseelsaeed
Copy link

Maybe a little late to the party. But changing the server side ReCaptcha class fixed it for me.

Original code

public function ReCaptcha ($secret) {
        if ($secret == null || $secret == "") {
            die("To use reCAPTCHA you must get an API key from <a href='"
                . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
        }
        $this->_secret=$secret;
}

changed to

public function __construct($secret) {
        if ($secret == null || $secret == "") {
            die("To use reCAPTCHA you must get an API key from <a href='"
                . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
        }
        $this->_secret=$secret;
       
    }

Hope that helps someone.

@nikleshraut
Copy link

Thanks @faseelsaeed, changing constructor method from same as class to __construct solved my problem.

@jorgedsdias
Copy link

The solution presented by @faseelsaeed works very well. Thanks

@MarcosBL
Copy link

MarcosBL commented Dec 7, 2023

Thanks @faseelsaeed ! working like a charm !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants