async function annotateAssessment(assessmentID, annotation, reasons, accountId) {
const annotateData = {
annotation: "", // "LEGITIMATE" or "FRAUDULENT"
reasons: reasons, // Optional array of reasons (e.g., ["AUTOMATION"])
accountId: "" // Optional, the identifier for the user's account on your website
};
try {
const response = await fetch(annotateUrl, {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify(annotateData),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer my token' , // Include your reCAPTCHA API token here
}
});
if (!response.ok) {
// Handle HTTP errors
const errorData = await response.json();
console.error("Error annotating the assessment:", errorData);
return;
}
const result = await response.json();
console.log("Annotation result:", result);
} catch (error) {
console.error("Error annotating the assessment:", error);
}
}
my token is generated and tried from below ways
1. OAuth 2.0 Playground
2. creating a new service account in google cloud (using that key) as well as downloading the json and replacing it with path
can someone reply the solution for above error and please tell if the way we are working for token generation is correct or wrong