I am trying to run the sample Vision API project. I basically copied and pasted the code Program.cs
into my application and executed it.
This line (which is line #36-#37 in Program.cs
)
GoogleCredential credential = GoogleCredential.GetApplicationDefaultAsync().Result;
throws a System.AggregateException
in mscorlib.dll
with Additional information: One or more errors occurred.
.
By examining InnerException
, I found out that the actual exception thrown is InvalidOperationException
with Error deserializing JSON credential data.
.
Nonetheless, my cloud project is a basic project, with a Service Account, and Cloud Vision API enabled, nothing else. I checked that my environment variable was set to the JSON file by writing:
Console.WriteLine(Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"));
before the line above. The output of that (just before the crash) is (something like):
C:\Users\me\Documents\Projects\MyProject\MyProject-ba31aae6efa1.json
I checked the file, and it is the file that I got when I enabled my service account. Every property in it looks fine (i.e. project name is correct, path's correct, ...).
I installed the Google Cloud SDK and executed gcloud beta auth application-default login
and authorized access to my cloud account.
Any ideas on what might be causing this?