May 9, 2018

Google ReCAPTCHA & K2

by Andrew Blinco in Enablement, Innovation, Proof, Video

Have you ever been to a website, and before you can submit or view information, you have had to verify that you are not a robot?

While this might be a bit annoying (of course you are not a robot!) there is a very good reason for doing this – to stop automated software, or “bots” from abusing the website. There is any number of “bad actors” out there who would like to exploit weaknesses in your site.

To try and sort the humans from the bots, CAPTCHA was invented as a way of testing who you were: man or a machine. CAPTCHA is an acronym that stands for Completely Automated Public Turing Test to Tell Computers and Humans Apart.


In the bad old days CAPTCHAs were usually images of squiggly text or numbers that you had to read and type into a text box, like the image below. They were not very friendly or pretty.

In 2009 Google acquired one of the CAPTCHA systems called reCaptcha. In the words of Google:

reCAPTCHA is a free service that protects your website from spam and abuse. reCAPTCHA uses an advanced risk analysis engine and adaptive CAPTCHAs to keep automated software from engaging in abusive activities on your site. It does this while letting your valid users pass through with ease.

reCaptcha is more user-friendly, asking users to verify you are not a robot by showing the user squares of images, and asking the user to select ones that meet a criterion, such as those having a street sign in them. You first tick the “I’m not a robot” box and then complete the test.

So, if you have a public facing website that allows users to view or submit information, you will probably be interested in stopping bots from running amok by using something like reCaptcha. What if your publicly facing form is using K2. Not to worry, you can quite easily add reCaptcha to your K2 forms.

The first thing you will need is a google account. If you don’t have one, visit Google and create one.

Then visit the reCaptcha site and click on the Get reCaptcha button and enter your Google login details.

Once you have logged in you will need to register your site. Give it a label and select the reCaptcha V2 option. You will need to enter the domain name for your K2 site (e.g. 

Once you have done this you will be shown the information needed to add reCaptcha to your site.

To add reCaptcha to your K2 form follow these steps:

  1. Create a new view (e.g. named “Google.Recaptcha.Verify.Item”)
  2. Add a data label to the view named “Recaptcha Script Data Label”
  3. Add an expression to your data label and add the following script to the expression, taking care to replace the highlighted value with your site key obtained above

<script type=”text/javascript”>var recaptchaCallback = function(response) {$(‘span[name=”Result Data Label”]’).SFCLabel(“option”, “text”, response);};</script><script src=’’ ></script> <div class=”g-recaptcha” data-sitekey=”<your site key>” data-callback=”recaptchaCallback”></div>

  1. Make sure you mark your data label as a literal
  2. Add another data label called “Result Data Label”

At this point you can run your view, and you should be able to verify you are not a robot. When you are verified your Result Data Label should have a long string in it:

Great! You have verified you are not a robot, however, this is only half the story. Even though Google has returned a response (that long string), you have not fully verified. This is because you need to send that response off to Google now and get back a final confirmation.  To do this you will need to call Googles URL. The best and easiest way to do this is via a K2 REST service.

To create a reCaptcha REST service instance you will need a swagger file. A swagger file describes the service and is used by K2 for it to create the Service Instance and related Service Objects. The quickest and easiest way to create this is by using a service like REST United.

There is only one endpoint needed –  the following images describe the steps to create it in Rest UNITED.

Once you have the swagger file (you can export this from RESTUnited, go to Test & Export, select Swagger and then Export) place it on a location (i.e. file share or website) accessible by K2.

You can now create a new REST Service Instance and add this location to the “Descriptor Location” setting for your service instance.

Once your Google reCaptcha service is created, you can generate the SmartObject you need to perform the verification. The Service Object you need will be called “ValidationResponse” if you followed the steps above for creating the swagger file in RESTUnited. You can ask K2 to create the SmartObject for you by using the “Generate SmartObjects” button on the Service Instances page in Management.

This SmartObject will have a single “Verify” method that you need to call. This method takes two parameters: secret and response. The secret parameter maps to the “secret key” that was generated for you by Google when you registered your site. The response parameter is the long string that was returned to your “Result Data Label”

Instead of having to add the “secret” parameter in every time you call this “Verify” SmartObject method, you can add it in as a specific value in the SmartObject method definition. Edit the SmartObject method and choose to bind “secret” to a specific value, and paste your secret key in (don’t worry if K2 reports the value as “undefined” as per the image below, it will retain the value).

Now when you call this method on your form you do not need to pass the secret key in.

So now you can complete the final piece of the puzzle, and send Google your response and secret and get verification that the user is not a robot!

  1. Add a new data label to your view called “Recaptcha Valid Data Label”. Optionally you can add another data label to hold any error codes returned by the verify call (e.g. add an “Error Codes Data Label”)
  2. Add a new unbound rule to your view called “Verify Recaptcha Response” and add an action to call a SmartObject method
  3. Select your “Validation Response” SmartObject created above and the “Verify” method.
  4. Configure the action and map the “Result Data Label” to the “response” input parameter, and the “Success” property to the “Recaptcha Valid Data Label” in the output mappings.

  1. You can now finish this view and add it to a form. On your form you can now call the “Verify reCaptcha Response” rule in response to an event on your form, such as a button click. You will first want to check that the “Result Data Label” has a value, so that you can tell if the user has tried the reCaptcha verification. Once you have called the rule to verify the response you can check the value in “Recaptcha Valid Data Label” to see if is true (passed) or false (failed), and then act accordingly.

You now have a re-usable view and pattern for implementing Google reCaptcha on any of your K2 forms!

One Comment

  1. 23 July 2019 at 8:16 pm

    Martello is ‘more than a T-shirt’ Bruce Linton wore:
    CEO. Everything you’ll need to learn about cryptocurrencies.
    mortgage brokers coquitlam Rents generally in most cities are
    unaffordable for lower-income earners: Study.
    We’ve sent a message with instructions to create a new password.

    Invis – Coquitlam Mortgage Brokers (604) 229-8474

  2. 24 July 2019 at 4:22 am

    I love your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you?
    Plz reply as I’m looking to construct my own blog and would like to find out where u got this
    from. many thanks

  3. 24 July 2019 at 6:10 am

    Propecia Cost Auckland Is Ceftin The Same As Cephalexin Cialis Sur Le Net buy generic cialis online 5 Day Prednisone Pack Where Can I Buy Omifin

  4. 24 July 2019 at 8:05 am

    With havin so much content and articles do you ever run into any problems of plagorism
    or copyright violation? My site has a lot of unique content I’ve
    either written myself or outsourced but it seems a lot of it is popping it
    up all over the web without my permission. Do you know any solutions to help
    prevent content from being ripped off? I’d certainly appreciate it.

  5. 24 July 2019 at 9:25 am

    Great goods from you, man. I’ve remember your stuff previous to and
    you’re just extremely magnificent. I really like what you have
    got right here, really like what you are stating and the best way wherein you say it.

    You’re making it enjoyable and you still care for to keep it
    wise. I cant wait to read much more from you. This is really a wonderful site.

  6. 24 July 2019 at 10:22 am

    Hello! I’m at work browsing your blog from my new iphone 4!

    Just wanted to say I love reading your blog and look forward
    to all your posts! Carry on the superb work!

  7. 24 July 2019 at 10:36 am

    I like the helpful information you supply on your articles.
    I will bookmark your weblog and take a look at once more right here frequently.
    I am quite sure I’ll be informed lots of new stuff proper here!
    Best of luck for the following!

  8. 24 July 2019 at 11:22 am

    I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes which makes it much more enjoyable for me
    to come here and visit more often. Did you hire out a
    designer to create your theme? Superb work!

  9. 24 July 2019 at 11:28 am

    Oh my goodness! Amazing article dude! Thank you so much, However I am going through troubles with your RSS.
    I don’t know why I am unable to join it. Is there anyone else getting
    identical RSS issues? Anyone who knows the answer will you kindly respond?

  10. 24 July 2019 at 11:52 am

    Heya i’m for the first time here. I found this board and I find It truly useful &
    it helped me out a lot. I hope to give something back
    and help others like you aided me.

  11. 24 July 2019 at 12:05 pm

    I am in fact happy to glance at this webpage posts which carries plenty of
    helpful facts, thanks for providing these statistics.

  12. 25 July 2019 at 3:44 pm

    Simply want to say your article is as surprising. The clarity in your
    publish is just great and i could think you are knowledgeable on this subject.
    Fine with your permission let me to clutch your feed to stay up to date with
    approaching post. Thanks 1,000,000 and please keep
    up the rewarding work.

  13. 26 July 2019 at 7:23 am

    Cialis 20 Prise Propecia Es Peligroso cheap cialis Drug Tadalis Sx Soft Sildenafil GСЂВ nСЂВ rique

  14. 26 July 2019 at 8:12 am

    Its not my first time to pay a quick visit this web site,
    i am visiting this web page dailly and get pleasant data from here
    all the time.

  15. 28 July 2019 at 1:06 am

    This is my first time visit at here and i am actually happy
    to read everthing at one place.

  16. 28 July 2019 at 2:57 am

    My spouse and I stumbled over here by a different web page and thought I should check things out.
    I like what I see so i am just following you. Look forward to looking over
    your web page repeatedly.

  17. 28 July 2019 at 4:20 am

    Hello very cool site!! Guy .. Excellent ..
    Wonderful .. I’ll bookmark your blog and take the feeds also?
    I’m glad to find numerous helpful information right
    here in the post, we’d like work out extra strategies on this regard,
    thanks for sharing. . . . . .

  18. 28 July 2019 at 11:00 am

    Asking questions are actually nice thing if you are not understanding anything totally, however this article offers nice understanding

  19. 28 July 2019 at 4:40 pm

    I’ve been surfing online more than 2 hours today, yet I never found any
    interesting article like yours. It’s pretty worth enough for me.
    In my view, if all website owners and bloggers made
    good content as you did, the net will be a lot more useful than ever before.

  20. Cruips
    28 July 2019 at 6:08 pm

    loans online with monthly payments
    cash advance

  21. toterron
    28 July 2019 at 11:06 pm

    cash loans today
    payday loans

  22. frowly
    29 July 2019 at 12:02 am

    cash advance detroit mi
    payday loans

  23. 29 July 2019 at 1:49 am

    Hi! I’m at work surfing around your blog from my new iphone!
    Just wanted to say I love reading your blog and look forward to all your posts!
    Keep up the fantastic work!

  24. 29 July 2019 at 5:41 am

    I’ve been surfing on-line more than 3 hours
    nowadays, but I never discovered any fascinating article like yours.

    It is pretty value enough for me. In my opinion, if all
    web owners and bloggers made excellent content material as you probably did, the web will
    be a lot more helpful than ever before.

  25. 29 July 2019 at 7:25 am

    Wow, that’s what I was searching for, what a information! present
    here at this webpage, thanks admin of this web site.

  26. 31 July 2019 at 11:55 pm

    Hi there! I know this is kinda off topic however , I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My blog addresses a lot of the same topics as yours and I believe we could greatly benefit from each other. If you are interested feel free to shoot me an email. I look forward to hearing from you! Great blog by the way!

  27. 1 August 2019 at 7:04 am

    I really love your blog.. Excellent colors & theme. Did you make this web site yourself?
    Please reply back as I’m attempting to create my very own website
    and would like to find out where you got this from
    or what the theme is called. Appreciate it!

  28. 1 August 2019 at 12:57 pm

    As the admin of this web site is working, no doubt very soon it will be well-known, due to its feature

  29. 2 August 2019 at 2:01 am

    Hello, I enjoy reading all of your post. I like to write a little comment to support you.

  30. 4 August 2019 at 6:45 am

    Everyone loves it when people get together and share ideas.
    Great blog, stick with it!

  31. 5 August 2019 at 4:13 am

    Wow, this paragraph is pleasant, my younger sister is analyzing these kinds of things,
    so I am going to let know her.

  32. 5 August 2019 at 5:33 am

    Great beat ! I would like to apprentice whilst you amend your website, how can i subscribe for a
    blog website? The account aided me a appropriate deal. I have been a little bit
    acquainted of this your broadcast offered brilliant transparent concept

  33. 5 August 2019 at 6:07 am

    It’s a pity you don’t have a donate button! I’d definitely donate
    to this superb blog! Iguess for now i’ll settle for bookmarking and adding your RSS feed
    to my Google account. I look forward to brand
    new updates and will share this blog with my Facebook group.

    Talk soon!

  34. 5 August 2019 at 7:40 am

    It’s truly a great and useful piece of info. I am satisfied that you
    shared this helpful information with us. Please stay us up to date like this.
    Thanks for sharing.

  35. 6 August 2019 at 4:40 pm

    I think that what you said made a bunch of sense.

    But, what about this? suppose you composed a catchier post
    title? I ain’t saying your information isn’t good., however suppose you
    added a post title that makes people desire more?
    I mean K2 ANZ | Google ReCAPTCHA & K2 is
    a little boring. You ought to glance at Yahoo’s home page and watch how they create article titles to grab people to open the
    links. You might try adding a video or a pic or two to grab readers
    interested about everything’ve written. Just my opinion, it would bring your posts a little livelier.

  36. 6 August 2019 at 7:50 pm

    I am now not certain the place you’re getting your info, but good
    topic. I must spend some time studying more or understanding more.
    Thanks for wonderful information I was on the lookout for
    this info for my mission.

  37. 6 August 2019 at 9:02 pm

    Very good blog! Do you have any helpful hints for aspiring writers?
    I’m hoping to start my own website soon but I’m a little lost on everything.
    Would you advise starting with a free platform like
    Wordpress or go for a paid option? There are so
    many options out there that I’m completely overwhelmed ..
    Any tips? Appreciate it!

  38. 7 August 2019 at 12:06 am

    Ԝһen some one searchеs for his essential thing, tһerefore
    he/she dеsires to be available that in detail,
    thus that thing is maintained over here.

  39. 7 August 2019 at 12:49 am

    If some one wishes to be updated with latest technologies after that he must be pay a quick visit
    this website and be up to date everyday.

  40. 7 August 2019 at 1:34 am

    Greetings! This is my first comment here so I just
    wanted to give a quick shout out and tell you I truly
    enjoy reading through your blog posts. Can you suggest any other blogs/websites/forums that cover the same topics?
    Many thanks!

  41. 7 August 2019 at 2:08 am

    Howdy, i read your blog from time to time and i own a similar one and i was
    just wondering if you get a lot of spam responses? If so how do you protect against it, any
    plugin or anything you can suggest? I get so much lately it’s driving me insane so any assistance is very much appreciated.

  42. 7 August 2019 at 2:12 am

    Great information. Lucky me I came across your website by chance (stumbleupon).
    I’ve bookmarked it for later!

  43. 7 August 2019 at 2:30 am

    Link exchange is nothing else except it is only placing the other person’s website link on your page at
    appropriate place and other person will also do same in support
    of you.

  44. 7 August 2019 at 2:53 am

    I all the time emailed this web site post page to all my contacts,
    because if like to read it afterward my contacts will too.

  45. 7 August 2019 at 5:12 am

    Hello There. I found your blog using msn. This is
    a very well written article. I will be sure to bookmark it and come back to
    read more of your useful information. Thanks for the post.

    I’ll certainly return.

  46. 7 August 2019 at 5:30 am

    Hello i am kavin, its my first time to commenting anywhere, when i read this
    article i thought i could also make comment due to
    this sensible article.

  47. 7 August 2019 at 6:52 am

    Currently it sounds like WordPress is the best blogging
    platform available right now. (from what I’ve
    read) Is that what you’re using on your blog?

  48. 7 August 2019 at 8:28 am

    With havin so much content do you ever run into any problems of
    plagorism or copyright infringement? My site has a lot of completely unique content I’ve either authored myself or
    outsourced but it appears a lot of it is popping it up all over the web without my agreement.
    Do you know any solutions to help prevent content from being ripped off?
    I’d really appreciate it.

  49. 7 August 2019 at 12:07 pm

    Hmm is anyone else having problems with the
    images on this blog loading? I’m trying to find out
    if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  50. 9 August 2019 at 12:38 am

    I love what you guys tend to be up too. Such clever
    work and reporting! Keep up the awesome works guys I’ve added you guys to my
    personal blogroll.

  51. 9 August 2019 at 6:31 pm

    Keep this going please, great job!

  52. 9 August 2019 at 9:12 pm

    My brother suggested I might like this web site.
    He was totally right. This post actually made my day. You cann’t imagine simply how
    much time I had spent for this info! Thanks!

  53. 9 August 2019 at 10:53 pm

    Hello there, I do believe your blog could be having web browser
    compatibility problems. When I look at your blog in Safari, it looks fine but when opening
    in IE, it has some overlapping issues. I simply wanted to give you a
    quick heads up! Aside from that, excellent website!

  54. 15 August 2019 at 8:40 am

    Ꮋello there! This post could not be wгitten any better!
    Reading this post reminds me of my previouѕ room mate! He
    always kept talҝing about thіs. I will forwarԀ this article to
    him. Pretty sure he will have a good read. Thank you fоr shɑring!

  55. 15 August 2019 at 10:40 am

    I like the hеⅼpfᥙl information you supply to your articles.
    I ѡill bookmark your weblog ɑnd chеck once more
    here regularly. I’m somewhat sure I’ll be іnformed many new stuff riɡht
    rigһt here! Good luck for thе folloԝing!

  56. 15 August 2019 at 11:18 am

    live roulette online spielen
    casino en ligne
    online internet casinos

  57. 15 August 2019 at 2:48 pm

    This is a very good tip especiallʏ to those fresh to the blogosphere.
    Brief but very precise info… Thanks for sharіng this one.
    A must read post!

  58. 15 August 2019 at 5:00 pm

    Everything is very open with a precise clarification of the challenges.
    It was really informative. Your website is very helpful.
    Thanks for sharing!

  59. 15 August 2019 at 6:15 pm

    It’s impressive that you are getting thoughts from this piece of writing
    as well as from our discussion made at this place.

  60. 15 August 2019 at 8:05 pm

    This is very interesting, You are an excessively professional blogger.

    I have joined your feed and sit up for looking for extra of your great
    post. Additionally, I have shared your web site in my social networks

  61. 15 August 2019 at 8:21 pm

    Thanks in favor of sharing such a pleasant thinking, piece of writing is pleasant, thats why i
    have read it completely

  62. 17 August 2019 at 7:32 pm

    What’s up to every one, the contents existing at this website are
    actually awesome for people knowledge, well, keep up the good work fellows.

  63. 17 August 2019 at 11:59 pm

    Нey I know this is off topic but I was wondering if yօu knew of any widgets I could add to my blog that automaticaⅼly tweet my
    newest twitter ᥙpdates. I’ve been ⅼooking for a plug-in like this
    foг quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run int᧐ anything.
    I tгuly enjoʏ reading your bl᧐g and I look forward to your new updates.

  64. 19 August 2019 at 3:16 am

    You can definitely see youг enthusiasm in the
    article you write. The ѕector hopes fоr more pɑssіonate writers such as you who are not ɑfraid to mention how they believe.
    Always go after your heart.

  65. 19 August 2019 at 3:42 pm

    Do you have a spam issue on this website; I also am a blogger, and I was wanting to know your situation; many of us have
    created some nice procedures and we are looking to exchange techniques
    with others, be sure to shoot me an e-mail if interested.

  66. 19 August 2019 at 10:37 pm

    Hеy there! Someone in my Myspace gгoup shared this
    ѕite with us sⲟ I came to taҝe ɑ look.
    I’m Ԁefinitely enjoying the informɑtion. I’m Ƅookmarking and will be
    tweeting this to my followers! Eⲭceptional bloց and gгeat design.

  67. 21 August 2019 at 10:15 am

    I think the admin of this web site is actually working hard in support of his web page, because here
    every material is quality based information.

  68. 21 August 2019 at 10:27 am

    An intriguing discussion is worth comment. I do believe that you
    ought to write more about this issue, it may
    not be a taboo matter but typically people do not talk about these topics.
    To the next! Kind regards!!

  69. 21 August 2019 at 7:23 pm

    My pɑrtner and I absolutely love your blog and find a lot of your
    post’s tօ be exactly what I’m looking for. Do you offer
    guest writегs to write cоntent for yoᥙrѕelf?
    I wouldn’t mind publishing a post or elaborating on a
    number of the subјects you write with regards to here.
    Αɡain, awesome web site!

Leave a Reply

Your email address will not be published.