hCaptcha / hcaptcha-wordpress-plugin

hCaptcha.com support for Wordpress (Plugin)
GNU General Public License v2.0
79 stars 32 forks source link

Usage with WP API #122

Closed n-kort closed 2 years ago

n-kort commented 2 years ago

I'm using hCaptcha/vue-hcaptcha and posting form data (including h-captcha-response) to /wp-json/wp/v2/comments. Always responds with 400 'Invalid Captcha' though. Any pointers as to how (or whether) this should work?

I've tried generating and including a hcaptcha_nonce or hcaptcha_comment_form_nonce but to no avail...

The captcha works fine on the WP login page.

e271828- commented 2 years ago

Hmm, seems likely to be nonce-related. Did you take a look at your backend logs?

n-kort commented 2 years ago

I didn't look at this again but yes, that is most likely the case :) I was returning the nonce from a custom endpoint but the user is always 0 in that context, so it will not (and probably shouldn't) work in that case.