Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo documento mostra come eseguire la migrazione dalla versione v1beta1 alla versione v1
dell'API reCAPTCHA Enterprise.
Per eseguire la migrazione delle chiamate di valutazione da v1beta1 a v1:
Sostituisci le chiamate per creare valutazioni.
Sostituisci https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments?key=API_KEY con https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY
Comprendi le modifiche nella risposta JSON della valutazione:
Quando utilizzi v1, i campi reasons e score sono incapsulati in
riskAnalysis nella risposta e, quando utilizzi v1beta1, i campireasons e
score non sono incapsulati nella risposta.
Aggiorna l'ambiente per utilizzare i campi reasons e score della risposta JSON per
v1.
Il seguente codice di esempio mostra i campi utilizzati dalla risposta di v1
e v1beta1:
v1
.....
.....
# Get the risk score and the reason(s)forreasoninresponse.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)forreasoninresponse.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 con https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate
Se al momento registri le chiamate API create e annotate utilizzando
gli audit log, ti consigliamo di utilizzare
i log della piattaforma
(disponibile solo per v1).
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Migrate to the v1 API\n\nThis document shows you how to migrate from the `v1beta1` version to the `v1`\nversion of the reCAPTCHA Enterprise API.\n| **Caution:** On August 31st, 2025, the `v1beta1` version of the reCAPTCHA Enterprise API will be deprecated. To avoid any disruption to your service, migrate to the `v1` version of the reCAPTCHA Enterprise API before August 31st, 2025.\n\nTo migrate your assessment calls from `v1beta1` to `v1`, do the following:\n\n1. Replace calls to create assessments.\n\n Replace `https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments?key=API_KEY`\n with `https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments?key=API_KEY`\n | **Note:** You can use the same API key.\n2. Understand the changes in the assessment's JSON response:\n\n When you use `v1`, the `reasons` and `score` fields are encapsulated in\n `riskAnalysis` in the response, and when you use `v1beta1`, the`reasons` and\n `score` fields are not encapsulated in the response. \n\n ### v1\n\n\n ```bash\n {\n \"event\":{\n \"expectedAction\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eEXPECTED_ACTION\u003c/var\u003e\",\n \"hashedAccountId\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\",\n \"siteKey\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eKEY_ID\u003c/var\u003e\",\n \"token\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTOKEN\u003c/var\u003e\",\n \"userAgent\":\"(USER-PROVIDED STRING)\",\n \"userIpAddress\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_PROVIDED_IP_ADDRESS\u003c/var\u003e\"\n },\n \"name\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eASSESSMENT_ID\u003c/var\u003e\",\n \"riskAnalysis\":{\n \"reasons\":[],\n \"score\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSCORE\u003c/var\u003e\n },\n \"tokenProperties\":{\n \"action\":\"USER_INTERACTION\",\n \"createTime\":\"TIMESTAMP\",\n \"hostname\":\"HOSTNAME\",\n \"invalidReason\":\"(ENUM)\",\n \"valid\":(BOOLEAN)\n }\n }\n ```\n\n \u003cbr /\u003e\n\n ### v1beta1\n\n\n ```bash\n {\n \"event\":{\n \"expectedAction\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eEXPECTED_ACTION\u003c/var\u003e\",\n \"hashedAccountId\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eACCOUNT_ID\u003c/var\u003e\",\n \"siteKey\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eKEY_ID\u003c/var\u003e\",\n \"token\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTOKEN\u003c/var\u003e\",\n \"userAgent\":\"(USER-PROVIDED STRING)\",\n \"userIpAddress\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_PROVIDED_IP_ADDRESS\u003c/var\u003e\"\n },\n \"name\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eASSESSMENT_ID\u003c/var\u003e\",\n \"reasons\":[],\n \"score\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eSCORE\u003c/var\u003e\",\n\n \"tokenProperties\":{\n \"action\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eUSER_INTERACTION\u003c/var\u003e\",\n \"createTime\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eTIMESTAMP\u003c/var\u003e\",\n \"hostname\":\"\u003cvar class=\"readonly\" translate=\"no\"\u003eHOSTNAME\u003c/var\u003e\",\n \"invalidReason\":\"(ENUM)\",\n \"valid\":(BOOLEAN)\n }\n }\n ```\n\n \u003cbr /\u003e\n\n3. Update your environment to use the `reasons` and `score` fields from the JSON response for\n `v1`.\n\n The following sample code shows the fields that are used from the response of `v1`\n and `v1beta1`: \n\n ### v1\n\n ```bash\n .....\n .....\n # Get the risk score and the reason(s)\n for reason in response.risk_analysis.reasons:\n print(reason)\n print(\n \"The reCAPTCHA score for this token is: \"\n + str(response.risk_analysis.score)\n )\n ....\n ....\n ```\n\n ### v1beta1\n\n ```bash\n .....\n .....\n # Get the risk score and the reason(s)\n for reason in response.reasons:\n print(reason)\n print(\n \"The reCAPTCHA score for this token is: \"\n + str(response.score)\n )\n ....\n ....\n ```\n4. Replace calls to annotate assessments.\n\n Replace `https://recaptchaenterprise.googleapis.com/v1beta1/projects/PROJECT_ID/assessments}:annotate`\n with `https://recaptchaenterprise.googleapis.com/v1/projects/PROJECT_ID/assessments}:annotate`\n5. If you are currently logging your `create` and `annotate` API calls using\n [audit logging](/recaptcha/docs/audit-logging) it is\n recommended to use\n [platform logging](/recaptcha/docs/platform-logging)\n (available for `v1` only).\n\nWhat's next\n-----------\n\n- [Create an assessment](/recaptcha/docs/create-assessment)\n- [Annotate an assessment](/recaptcha/docs/annotate-assessment)"]]