I am trying to run a sample Vision API project. I basically copied and pasted the Program.cs code into my application and executed it.
This line (line No. 36- # 37 in Program.cs )
GoogleCredential credential = GoogleCredential.GetApplicationDefaultAsync().Result;
throws a System.AggregateException in mscorlib.dll using Additional information: One or more errors occurred. .
Having examined InnerException , I found that the actual exception was an InvalidOperationException with Error deserializing JSON credential data. .
However, my cloud project is a basic project that includes a service account and Cloud Vision API, nothing more. I checked that my environment variable was set to a JSON file by writing:
Console.WriteLine(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"));
before the line above. The result of this (just before the crash) is (something like):
C:\Users\me\Documents\Projects\MyProject\MyProject-ba31aae6efa1.json
I checked the file and this is the file that I received when I turned on my service account. Each property in it looks normal (i.e. the project name is correct, the correct path, ...).
I installed the Google Cloud SDK and executed gcloud beta auth application-default login and allowed access to my cloud account.
Any ideas on what could be causing this?
c # google-cloud-platform google-cloud-vision
Rakete1111
source share