[*]Project Name
I tried the below libraries to inegrate
- Safety Net(Deprecated)
- Recaptcha
Googlecertificationatesrslt: не допускается: pkg = com.recaptchademo, sha256 = [my sha256], atk = false, ver = 251036032.true (go/gsrlt): null [context service_id = 247]
e urr/e in vired: null [in vinduls_id = 247]. Ключ < /p>
Мой код приведен ниже < /p>
Безопасная сеть < /p>
@composable
Fun safetynetrecaptcha () {
val context = localcontext.current
var token с помощью {mutablateOf Unit,
onFailure: (Exception) -> Unit
) {
SafetyNet.getClient(context)
.verifyWithRecaptcha(siteKey)
.addOnSuccessListener { response ->
if (!response.tokenResult.isNullOrEmpty()) {
onSuccess(response.tokenResult ?: "")
} else {
onFailure(Exception("Empty token"))
}
}
.addOnFailureListener {
onFailure(it)
}
}
< /code>
< /li>
recaptcha < /p>
@composable
Fun recaptChascReen () {
val siteKey =
"My Site Key" // Заменить с помощью вашего recaptcha v3 -ware
var varified {mutablestate (recaptcha v3 -warmes
var var warmess). By Memple {mutablestateof (null)} < /p>
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center
) {
val context = LocalContext.current
if (isVerified) {
Text("User Verified Successfully!")
} else {
Button(onClick = {
verifyReCaptcha(
context = context,
siteKey = siteKey,
action = RecaptchaAction("verify_action"), // Use RecaptchaAction here
onVerified = { isVerified = true },
onError = { errorMessage = it }
)
}) {
Text("Verify with reCAPTCHA")
}
}
errorMessage?.let {
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "Error: $it",
color = Color.Red
)
}
}
< /code>
} < /p>
Fun verifyRecaptcha (
context: context,
sitekey: string,
action: recaptchaaction,
onverifified: () -> Unit,
onerror: (string) -> Unit
) {
val recap Recaptcha.getClient (контекст) < /p>
// Step 1: Initialize RecaptchaHandle
recaptchaClient.init(siteKey)
.addOnCompleteListener(OnCompleteListener { initTask ->
if (initTask.isSuccessful) {
val recaptchaHandle = initTask.result // RecaptchaHandle is created here
// Step 2: Execute reCAPTCHA using the RecaptchaHandle and action
recaptchaClient.execute(recaptchaHandle, action)
.addOnCompleteListener(OnCompleteListener { executeTask ->
if (executeTask.isSuccessful) {
val resultData =
executeTask.result // RecaptchaResultData is obtained here
val responseToken =
resultData.tokenResult // This is the token to send to your backend
if (responseToken.isNotEmpty()) {
onVerified()
} else {
onError("Empty response token!")
}
} else {
onError(executeTask.exception?.message ?: "Unknown error occurred!")
}
})
} else {
onError(initTask.exception?.message ?: "Failed to initialize reCAPTCHA!")
}
})
< /code>
} < /p>
< /li>
Играть в целостность: < /p>
< /li>
< /ol>
Если я использую целостность воспроизведения, я получаю токен, но диалог captcha не открывается. Итак, правильная интеграция целостности игры?
Пожалуйста, помогите мне с этим.
Подробнее здесь: https://stackoverflow.com/questions/795 ... captcha-v3
Мобильная версия