提取Google凭证的默认路径Json时出错

时间:2018-06-28 09:46:15

标签: c# google-api ocr google-vision

错误日志:

  

InnerException:System.InvalidOperationException:读取错误   来自位置OCR-c812724b.json的凭证文件:无法   找到文件'C:\ Windows \ SysWOW64 \ inetsrv \ OCR-c812724b.json'。   请检查环境变量的值   的GOOGLE_APPLICATION_CREDENTIALS   Google.Apis.Auth.OAuth2.DefaultCredentialProvider.d__11.MoveNext()

下面是我的.cs代码

Response.Write("<BR>GCLOUD_PROJECT:" + 
Environment.GetEnvironmentVariable("GCLOUD_PROJECT"));
Response.Write("<BR>GOOGLE_APPLICATION_CREDENTIALS:" + 
Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS"));
string[] delimiters = new string[] { "\n" };

var credential = GoogleCredential.GetApplicationDefault(); <-- Error here
Response.Write("<BR>Test for credentials" + credential);

有人有解决方案吗?

0 个答案:

没有答案