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.