When using image character recognition, I want to check whether the json I am using is valid or invalid.

128 views
Skip to first unread message

it isd

unread,
Feb 6, 2022, 11:43:58 PM2/6/22
to cloud-vision-discuss
Creation Environment
Language: c#
Nuget: Google.Cloud.Vision.V1 v2.4.0
Development software: Visual Studio 2013

I am working on a program that uses google cloud vision to get the text of a passed image.
When I do DetectDocument() on a client created with a disabled json file, an error occurs, so I would like to determine whether the json file is valid or invalid before DetectDocument, and then abort the process.

The error that occurs is as follows

An unhandled exception of type 'Grpc.Core.RpcException' was thrown in TestOCR.dll Additional Information:Status(StatusCode=" Unauthenticated", Detail="Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie, or other valid authentication credential. Expected OAuth 2 access token, login cookie, or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", Core.Internal.CoreErrorDetailException: CoreErrorDetailException: {"created":"@1644195460.050000000", "description": "Error received from peer ipv4:216.58.220.106:443", "file":"...\src\core\lib\surface\call.cc", "file_line":1067, "grpc_message": "Request Had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. https://developers.google.com/identity/sign-in/web/devconsole-project.", "grpc_status":16}")

For character recognition, the code is as follows

var clb = new ImageAnnotatorClientBuilder(); 
clb.CredentialsPath = ". /key.json"; 
ImageAnnotatorClient client; 
client = clb.Build(); 
var Result = client.DetectDocumentText(". /Image.png");

please treat me well.

Carlos Clement Bellido

unread,
Feb 7, 2022, 11:57:41 AM2/7/22
to cloud-vision-discuss

Hi!

It seems that there is some type of OAuth2 issue there, could you try using service account application credentials as mentioned in the docs?
Reply all
Reply to author
Forward
0 new messages