Questo documento mostra come eseguire la migrazione dalla versione v1beta1
alla versione v1
dell'API reCAPTCHA Enterprise.
Se utilizzi v1beta1
per creare e annotare le valutazioni, ti consigliamo di usare v1
perché le nuove funzionalità, come l'account defender reCAPTCHA Enterprise, sono disponibili solo su v1
. v1
supporta l'autenticazione tramite chiave API e account di servizio.
Per eseguire la migrazione delle chiamate di test da v1beta1
a v1
:
Sostituisci le chiamate per creare le valutazioni.
Sostituisci
https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments?key=API_KEY
conhttps://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY
Comprendi le modifiche nella risposta JSON del test:
Quando utilizzi
v1
, i campireasons
escore
vengono incapsulati inriskAnalysis
nella risposta, mentre quando utilizziv1beta1
, i campireasons
escore
non vengono incapsulati nella risposta.v1
{ "event":{ "expectedAction":"EXPECTED_ACTION", "hashedAccountId":"ACCOUNT_ID", "siteKey":"KEY_ID", "token":"TOKEN", "userAgent":"(USER-PROVIDED STRING)", "userIpAddress":"USER_PROVIDED_IP_ADDRESS" }, "name":"ASSESSMENT_ID", "riskAnalysis":{ "reasons":[], "score":"SCORE }, "tokenProperties":{ "action":"USER_INTERACTION", "createTime":"TIMESTAMP", "hostname":"HOSTNAME", "invalidReason":"(ENUM)", "valid":(BOOLEAN) } }
v1beta1
{ "event":{ "expectedAction":"EXPECTED_ACTION", "hashedAccountId":"ACCOUNT_ID", "siteKey":"KEY_ID", "token":"TOKEN", "userAgent":"(USER-PROVIDED STRING)", "userIpAddress":"USER_PROVIDED_IP_ADDRESS" }, "name":"ASSESSMENT_ID", "reasons":[], "score":"SCORE", "tokenProperties":{ "action":"USER_INTERACTION", "createTime":"TIMESTAMP", "hostname":"HOSTNAME", "invalidReason":"(ENUM)", "valid":(BOOLEAN) } }
Aggiorna il tuo ambiente per utilizzare i campi
reasons
escore
della risposta JSON perv1
.Il seguente codice campione mostra i campi utilizzati dalla risposta di
v1
ev1beta1
:v1
..... ..... # Get the risk score and the reason(s) for reason in response.risk_analysis.reasons: print(reason) print( "The reCAPTCHA score for this token is: " + str(response.risk_analysis.score) ) .... ....
v1beta1
..... ..... # Get the risk score and the reason(s) for reason in response.reasons: print(reason) print( "The reCAPTCHA score for this token is: " + str(response.score) ) .... ....
Sostituisci le chiamate per annotare le valutazioni.
Sostituisci
https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments}:annotate
conhttps://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate
Se attualmente registri le tue chiamate API
create
eannotate
utilizzando l'audit logging, ti consigliamo di utilizzare l'logging della piattaforma (disponibile solo perv1
).