First time implementing reCaptcha Enterprise on the backend, and I'm receiving "Invalid resource field value in the request" when I attempt to create an Assessment. I am unsure what to troubleshoot.
I'm using a slightly-modified version of the tutorial code found here: https://cloud.google.com/recaptcha-enterprise/docs/create-assessment#c
The modification I've made is I'm using JSON credentials to authenticate since we aren't running on Google Cloud. Here is my code snippet:
string SiteKey = "x";
string Token = "x";
string AssessmentName = "GarrisonTestAssessment";
string ParentProject = "project/x";
string RecaptchaAction = "ORDER";
var jsonCredentials = File.ReadAllText("creds.json");
var test = new RecaptchaEnterpriseServiceClientBuilder();
test.JsonCredentials = jsonCredentials;
var client = test.Build();
CreateAssessmentRequest createAssessmentRequest = new CreateAssessmentRequest()
{
Assessment = new Assessment()
{
Event = new Event()
{
SiteKey = SiteKey,
Token = Token,
ExpectedAction = RecaptchaAction
},
Name = AssessmentName,
},
Parent = ParentProject
};
Assessment response = client.CreateAssessment(createAssessmentRequest);
JSON Credentials look like this:
{
"type": "service_account",
"project_id": "x",
"private_key_id": "xx",
"private_key": "xxx",
"client_email": "xxxx",
"client_id": "xxxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "xxxxxx"
}
Error message looks like this:
Grpc.Core.RpcException HResult=0x80131500 Message=Status(StatusCode="InvalidArgument", Detail="Invalid resource field value in the request.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1622143781.065000000","description":"Error received from peer ipv4:x.x.x.x:443","file":"......\src\core\lib\surface\call.cc","file_line":1068,"grpc_message":"Invalid resource field value in the request.","grpc_status":3}")