Creating a Secure token with PHP for the Recaptcha V2

697 views
Skip to first unread message

Ithica

unread,
Jul 22, 2015, 5:23:02 AM7/22/15
to reCAPTCHA
Hi all,

has anyone managed to create  a secure token for the new V2 recaptcha ?

In the developper's guide, it says :

1 - Prepare a token in json format
    {"session_id": e6e9c56e-a7da-43b8-89fa-8e668cc0b86f,"ts_ms":1421774317718}
Ok, fine ...
2 - Encrypt it with your site secret, after encryption it looks like this:
    "Fg2rtWDZ6kf_Cc1fZs5xKJWnkkVvZgNCF-5fVhPS5_r1fB2NRXPg3WobIUUsyOvfN-ElyBz3zz29lK5v9NE0ByWrGzicUWecnoV8hwSb6W4"
Right .... the problem is, how do you encrypt your token with your private key ?
Google's guide only provides examples in Java on Github... and i've been searching on the web for a simple and neat explanation without success ...
Does anyone knows a tutorial or guide for PHP users ?

Mr Larry Page, if you ever read my request ( :-) ), could one of your top developper could add more information in the secure token section, that would be greatly appreciated ;-)
For now, i'm keeping an eye on this post on Stackoverflow, hoping for a solution :
http://stackoverflow.com/questions/31478724/how-to-generate-a-google-recaptcha-v2-secure-token-with-php

Dayjo

unread,
Aug 6, 2015, 6:38:20 AM8/6/15
to reCAPTCHA
Hi Ithica,

Try this; https://github.com/slushie/recaptcha-secure-token this is working for me

dr.ji...@gmail.com

unread,
Oct 14, 2015, 10:45:12 AM10/14/15
to reCAPTCHA
Hi Dayjo,
I also followed exactly the solution of slushie and have the captcha displayed sucessfully on localhost environment. However when I start testing on the server, I got the error: invalid stoken.

Do you have some ideas of that? Or did you make some special changes regarding to the code base of slushie?

Thanks
Reply all
Reply to author
Forward
0 new messages