I have a Vue-Express application which has signup/signin pages.
On both pages, I use the google captcha v2 invisible setting so I manually call the execute function for which I get a valid token
03AEkXODA0y6WEjvR8wd507P9Bnmm63hcOP2gMGJBsuN7PFpFJbeGE3r2M-3btinH4xMIu3OeFnpmLwrwJvlhPbyX7dkCzD_3jnbytUr7wrLC0X55O7qO3wrlF94H2ydekNYPutxvj-XaRKWcq_Dw96B5zSuc7h0xqqJgbao54jqHEB3RC5C0MWPkI6tf44TydsUscwlas9lKHG5tQZYNkOdtVwael4SUJuCvs6A5EADsKnUUKHOvfMX1a3-BUDC3fy1bRmqc7uGrmu-_6UUxNN10-7jR_9Cu9AZq94DGQ8YTnN0OJ0Jl_3w5ehl1HToAkW-RX4xWZsJlprccUm8P2Pk30W_KVGrm7W-N_z9w0c-MdFZfH7qV1xkf_hHO6hidvf_WYB_Sw8fBujV8PihixKSH6DKtsn3rVX4tA9BuyxVTTse4g1skqmpxF4Lp3CjAtzRJWwbtKLYCNHy0cTyIZ2AAR1v9QLMY4Mlz5DXIuFb4YTecvsjlxTG6F09gGjMWrWiQ4H-6q7BfE
I then pass this to the express app which calls the google api
https://www.google.com/recaptcha/api/siteverify?secret=<recaptcha_secret_key>&response=<token>
The same request if sent via postman gives
{
"success": false,
"error-codes": [
"timeout-or-duplicate"
]
}
I am not sure what is wrong here, any help is appreciated.
UPDATE: How I got the token:
I call the onCaptchaVerified when the signin button is clicked and it is called again by the captcha component with the valid token
<vue-recaptcha
ref="recaptcha"
size="invisible"
verify="onCaptchaVerified"
expired="onCaptchaExpired"
sitekey="sitekey"
/>
async onCaptchaVerified(token) {
await this.$refs.recaptcha.execute()
if(!token) {
return false
}
console.log("logging in...", token);
const res = await postRequest('validate-human', {
token: token
)}
console.log(res.data.data)
}
Duplicate of this post ReCAPTCHA siteverify not returning JSON response
TLDR:
Issue was caused by Axios version 1.2.0 Reverting to 1.1.0 solved the problem.
This might not have occurred if I would have used the fetch API