Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make google Recaptcha work with special characters in the domain name

I was setting up an API key for a site with the swedish charachter ä in the domain name (http://sälja.io) but it did not initialize the recaptcha.

Then trying an api key for the equivalent url http://xn--slja-loa.io which worked when reaching the site from http://xn--slja-loa.io but not http://sälja.io.

Then I found the secure token which should work on all domains. It initialized the recaptchas on all domains and was also working on all tested domains, except the one with ä in it. https://developers.google.com/recaptcha/docs/secure_token

Is there any way to get it working also with ä in the domain name ?

Edit

Since an api-key for http://xn--slja-loa.io is working from android when accessing the site from http://sälja.io, it might be how the browser interprets the domain. Eg. firefox interprets http://sälja.io as domain http://sälja.io and cannot get a response from google servers that will not allow ä in domain names. Android inteprets http://sälja.io as http://xn--slja-loa.io and will get a response since it's not containing ä. Any thoughts about this ? Is there any way to force the browser to interpret http://sälja.io as http://xn--slja-loa.io ?

Edit2

Code examples can be reached on sälja.io/test, 178.62.187.163/test and xn--slja-loa.io/test

Edit3

As of today (25.11.2015) it seems not to be possible to use recaptcha with a special charachter like ä in the domain name. Since aishwat singh have been helping the most to coming to this conclusion within the time for the bounty he will be rewarded, however an answer will be accepted when a solution can be provided for this problem.

like image 770
embe Avatar asked Nov 15 '15 19:11

embe


People also ask

Why does reCAPTCHA say invalid domain?

If you are using reCAPTCHA on your site and you see the error 'ERROR for site owner: Invalid domain for site key', this means your site key is no longer valid. Also, your website url must match exactly what is included in the site key settings. Subdomains don't need to be added separately.

What is domain name for reCAPTCHA?

A reCAPTCHA key is normally tied to a set of individual domains or package names. For web users, the API key pair is unique to the domains and first-level subdomains that you specify. Specifying more than one domain could come in handy if you serve your website from multiple top level domains.


1 Answers

I tried it just now and I am able to generate key for example-ä.se 6Ld8VRETAAAAALRXFNxmjEeVzbg2y5vdWv7THwJz

will post a complete working example shortly


EDIT 1

Here's git repo for code and same running on heroku

Ok it's not a complete fix because i used herokuapp.com as domain so example-ä.herokuapp.com becomes a sub domain and works

(however when earlier i tried it created a key for example-ä.se too but on loading page at captcha it gives invalid domain, figured out that was original issue, i thought you were not able to generate key for this domain)

Will try for a complete fix


EDIT 2

Btw you can specify your domain ip too, check this discussion

For me heroku free account doesn't provides ip of domain so it's difficult for me to test it

Also i was reading this thread

Figured out if i specify domains list as just com it accepts. In your case, just specify se as domains and it should work , google doesn't checks out exact url it just checks domain

domain description

Hope it helps, Will look into stoken approach too

like image 128
Aishwat Singh Avatar answered Oct 24 '22 01:10

Aishwat Singh