Comments (22)
For any still looking for the answer to this question, @jamescodesthings has a note in the documentation for cordova-plugin-recaptcha:
Provided the reCAPTCHA's domains to check includes 'localhost' and your app's config.xml includes:
<allow-navigation href="https://www.google.com/recaptcha/*" />
This addition got reCaptcha working for me in iOS. (reCaptcha was working out of the box on Android)
from recaptcha.
from recaptcha.
Hello @vicjohnson1213, I'm using Cordova too, have disabled the domain validation, still, getting the error Error for site owner. Invalid domain for site key
, tried this <allow-navigation href="https://www.google.com/recaptcha/*" />
(however didn't install the plugin)
As discussed/mentioned in various forums since Cordova doesn't contain a domain name, all the files are accessed using file://)
Any suggestions/help, please!
from recaptcha.
@jamescodesthings very thanks! your plugin is for Angular 1, right? I need this functionality for Angular 2 or higher. I don't know how to use your plugin in my template.
from recaptcha.
No worries, it's a mixture of plain JS and Angular 1, but I kept to a fairly plain plugin format so that this wouldn't be too big a problem when I chuck it in an NG 2+ project.
Bear with me, it's been a little while since I did this in NG 2+.
In theory you can just use the plain JS version without too much hassle. You could create a service that then has access to the window object. From SO, something like:
import {provide} from '@angular/core';
bootstrap(..., [provide(Window, {useValue: window})]);
constructor(private window: Window) {
// this.window
}
Then just use the plain js from window:
window.plugins.recaptcha.verify('site-key', success_callback, fail_callback);
In practice it depends a little on what your template is, do you have a public copy or an idea of how you're currently working? I could help fudge it on in.
from recaptcha.
This seems to be a recent change - this used to work with localhost I'm pretty sure, even without localhost defined as one of the domains.
UPDATE: This does not actually seem to be recent. The main problem is that file: is used as the protocol for cordova projects. See here for the clearest description of what's going on: https://groups.google.com/forum/#!topic/recaptcha/AuN2f7JrZTA
from recaptcha.
Any update about this?
from recaptcha.
@fermedina or any other poor soul who ends up here.
I'll write this up a little better once it's production ready for my org, but to help in the mean time:
You can use a web recaptcha on iOS using the Ionic Web View, provided your recaptcha includes localhost
as a whitelisted domain. The reason this works is the Ionic Web View uses a local server to help with CORS on iOS. So your app has a domain which is localhost:8080
.
For Android it's a little more difficult, because your app won't have a domain, I investigated doing similar in Android as Ionic's Web View does for iOS (serving the app locally) but this leads to further complications. More than it's worth.
So, in lieu of a great solution I wrapped the Android Recaptcha code in a Cordova Plugin. You can find it here: cordova-plugin-recaptcha.
To do this you need an Android Recaptcha key, so your server-side may also need to account for multiple recaptcha sources. We did this by passing a flag for android to switch between the iOS and Android secret keys when validating the recaptcha.
In our own implementation in the cordova app, I then used cordova-plugin-device to check that the platform
is iOS before serving the web recaptcha key with the site key for our web recaptcha. In the android version we check platform
is android before making a call to the cordova plugin.
I can't guarantee it passes App Store Review as our app isn't yet in Prod, but it works as we need it to, validating recaptcha with our public-facing services for both android and iOS.
If you go down this route and have any trouble with the plugin please let me know. At the moment it hot-loads an Angular 1.x service in the js code because this was what we needed in our solution, but I could happily take this out if it causes anyone more trouble than its worth. I can also publish to NPM if it's of benefit, we originally planned to publish to our org's NPM repo but cordova doesn't play well with organisation scoped packages so we've held off, we can quite happily publish as a plain old NPM package upon request.
from recaptcha.
This sounds like it would make a pretty good blog post. I'm also updating the library to support Android app validation amongst other things on the v1.2
branch, so that may help. Let me know if there's something you need in the library here.
from recaptcha.
Any updates on this? We are facing the same issue. And we need to use it in our project.
We tried everything said in this post and a bunch of other things.
from recaptcha.
For any still looking for the answer to this question, @jamescodesthings has a note in the documentation for cordova-plugin-recaptcha:
Provided the reCAPTCHA's domains to check includes 'localhost' and your app's config.xml includes:
<allow-navigation href="https://www.google.com/recaptcha/*" />
This addition got reCaptcha working for me in iOS. (reCaptcha was working out of the box on Android)
this literally saved me, i looked for a few hours and this was the thing that was missing, thank you!!
from recaptcha.
Some updates on this? Thanks.
from recaptcha.
@k-sai-kiranmayee I'm not sure about that one. Sounds more like an issue with the ReCaptcha configuration more than the Cordova setup.
I wish I had more to help, but this Stack Overflow question has a few things you might want to try: https://stackoverflow.com/questions/30735694/recaptcha-error-invalid-domain-for-site-key
from recaptcha.
Thank you @vicjohnson1213 for the quick response and suggestion :)
I have already seen that question, however, in my case, the domain check is already disabled :( and I'm still getting that issue in the Cordova native app (works fantastically in web and mobile browser)
In https://www.google.com/recaptcha/admin, at the time of registration, we must specify at least one domain, later have unchecked the below and saved it
So now there won't be any domain validation right?
Any more information as to this origin (file://), please
Thank you!
from recaptcha.
@k-sai-kiranmayee I doubt it's an issue with the file://
protocol since I haven't had any issues around that. Do you have localhost
in your list of allowed domains? I'm not too sure exactly what that checkbox does, so it might be worth trying.
from recaptcha.
I doubt it's an issue with the
file://
protocol since I haven't had any issues around that
@vicjohnson1213 Oh! Thank you, just a quick question, have you installed any plugin or other changes for this in cordova.xml or only <allow-navigation href="https://www.google.com/recaptcha/*" />
this is added?
And yes, tried your suggestion, have added only by adding localhost as domain, still the same :(
And really thank you for your help and responses :)
from recaptcha.
@k-sai-kiranmayee Yeah, I was using the angular2-reacaptcha package (this was an Ionic app, hence the angular). But I can't see anything else in our code that I think would have any effect.
from recaptcha.
oh...Okay...I see that package is for the usage of ReCaptcha @vicjohnson1213 I'm using Vue, so used this vue-recaptcha-v3 and ours is a Cordova app built using Bitrise
Thank you for the help till now, and please do tell me if you find anymore :)
from recaptcha.
Hello, @vicjohnson1213 One more question please, which reCaptcha are you using?
from recaptcha.
@k-sai-kiranmayee I think we're using invisible v2.
from recaptcha.
oh, thank you @vicjohnson1213, so following this SafetyNet reCAPTCHA API?
from recaptcha.
Hello, everyone!
Has someone been lucky to fully clearing this out?
I have reCaptcha V3, and on my Cordova iOS app there is no window.grecaptcha object, means link to script is not even attached.
I have somewhat following settings
*COMMON*
<access origin="https://*.google.com/*"/>
<allow-navigation href="*://localhost"/>
<allow-navigation href="https://www.google.com/recaptcha/*" />
platform=ios
<preference name="Hostname" value="myapp.local" /> (cordova-plugin-ionic-webview)
<allow-navigation href="http://myapp.local/*" />
<allow-navigation href="https://www.google.com/recaptcha/*" />
and in my google recaptcha console i have _localhost and myapp.local_ declared
still cant get it work on cordova iOS and Android.
Help, anyone?
from recaptcha.
Related Issues (20)
- Seeing millions of false 0.1 scores per 90 day period
- There is an access limit on https://www.google.com/recaptcha/api.js
- Site limits for API based on IP HOT 1
- recaptcha times out then cannot be clicked
- Response is always Please click on the ReCaptcha box
- Constant Please try Again, audio option doesn't work, no fallback - effectively locked out of site
- Recaptcha V2 just spins HOT 21
- width adjustment based on the small screen mobile devices. for a Recaptcha with multiple images ,user needs to scroll down to see verify button. Is there a way to adjust the height of image select section. HOT 1
- Please get your SH!T together Google
- Bubble is not respossive HOT 2
- With recaptcha -- Without recaptcha
- Compatibility of verify method with token generated with recaptcha Enterprise
- FUCK RECAPTCHA HOT 4
- reCaptcha loops indefinitely when tracking protection is used HOT 2
- reCAPTCHA does not work properly in some Firefox environments
- Google is Evil HOT 1
- Define Response::toArray() return type.
- Chrome Issue: recaptcha Reading cookie in cross-site context will be blocked in future Chrome versions
- Fucking stupid verification system, are you guys going to stop? Testing the real person, you can't defend against hacker attacks, you can only defend against real people HOT 3
- Recaptcha clients hitting servers with an api2/clr POST call (resulting in 404s and bans in mod_security) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recaptcha.