android – Recaptcha:Andorid: Invalid site key error-ThrowExceptions

Exception or error:

I want put a captcha to my contact activity for my android application. Also I use google recaptcha api. When I create recaptcha api , I get domain’s name my application package name and also get label’s name somthing like ‘My application…’.

In android side my recaptcha integration is below…

protected  void handleSiteVerify(final String responseToken){
        //it is google recaptcha siteverify server
        //you can place your server url
        String url = "";
        StringRequest request = new StringRequest(Request.Method.POST, url,
                new Response.Listener<String>() {
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonObject = new JSONObject(response);
                                //code logic when captcha returns true Toast.makeText(getApplicationContext(),String.valueOf(jsonObject.getBoolean("success")),Toast.LENGTH_LONG).show();
                        } catch (Exception ex) {
                            Log.d("jsonErr", "JSON exception: " + ex.getMessage());

                new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError error) {
                        Log.d("err", "Error message: " + error.getMessage());
                }) {
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<>();
                params.put("secret", SiteSecretKey);
                params.put("response", responseToken);
                return params;
        request.setRetryPolicy(new DefaultRetryPolicy(

    public void onClick(View v) {
                .addOnSuccessListener(ContactActivity.this, new OnSuccessListener<SafetyNetApi.RecaptchaTokenResponse>() {
                    public void onSuccess(SafetyNetApi.RecaptchaTokenResponse response) {
                        if (!response.getTokenResult().isEmpty()) {
                .addOnFailureListener(ContactActivity.this, new OnFailureListener() {
                    public void onFailure(@NonNull Exception e) {
                        if (e instanceof ApiException) {
                            ApiException apiException = (ApiException) e;
                            Log.d("err", "Error message: " +
                        } else {
                            Log.d("err", "Unknown type of error: " + e.getMessage());

Api response says me “Invalid site key”.
In my opinion , I make some mistakes when creating recaptcha api on google/recaptcha. And What must I do , in order to solve this issue ?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *