This SDK provides a wrapper for ARCaptcha. You will need to configure a site key
and a secret key
from your arcaptcha account in order to use it.
// Register JitPack Repository inside the root build.gradle file repositories { maven { url 'https://jitpack.io' } } // Add ARCaptcha sdk dependency inside the app's build.gradle file dependencies { implementation 'com.github.sadeghb97:arcaptcha_android_sdk:0.0.1' }
The following snippet code will ask the user to complete a challenge.
ArcaptchaDialog.ArcaptchaListener arcaptchaListener = new ArcaptchaDialog.ArcaptchaListener() {
@Override
public void onSuccess(String token) {
Toast.makeText(MainActivity.this, "Puzzle Solved, Token Generated!",
Toast.LENGTH_LONG).show();
arcaptchaDialog.dismiss();
Log.d("Token: [" + token + "]");
txvLog.setText("ArcaptchaToken: \n" + token);
}
@Override
public void onCancel() {
arcaptchaDialog.dismiss();
}
};
arcaptchaDialog = ArcaptchaDialog.getInstance(YOUR_API_SITE_KEY,
DOMAIN, arcaptchaListener);
arcaptchaDialog.show(getSupportFragmentManager(), "arcaptcha_dialog_tag");
Name | Values/Type | Required | Default | Description |
---|---|---|---|---|
siteKey |
String | Yes | - | This is your sitekey, this allows you to load challenges. If you need a sitekey, please visit ARCaptcha, and sign up to get your sitekey. |
domain |
String | Yes | - | - |
After retrieving a token
, you should pass it to your backend in order to verify the validity of the token by doing a server side check using the ARCaptcha secret linked to your sitekey.