Google Api默认凭据

时间:2017-05-02 10:30:20

标签: oauth google-api xamarin.android google-cloud-vision

我正在尝试在Xamrin android中使用一个简单的应用程序 Google Vision API

我做的是,

已安装

  1. Google云视觉v1,
  2. Google.Apis.Auth.OAuth2;
  3. Newtonsoft.Json;
  4. 来自NuGet经理的xamarin.android项目。

    我创建了

    1. API密钥,
    2. 服务帐户,
    3. OAuth 2.0客户端ID
    4. 来自谷歌云控制台的

      我创建了GOOGLE_APPLICATION_CREDENTIALS(Environmenta变量) 并链接那些Json文件(服务帐户和 OAuth 2.0客户端ID json)尝试了两种方法。

      然后我只是从谷歌愿景API文档复制代码。

      // Load an image from a local file.
      var image = Image.FromFile(filePath);
      var client = ImageAnnotatorClient.Create();
      var response = client.DetectLogos(image);
      foreach (var annotation in response)
      {
      if (annotation.Description != null)
          textView.Text = (annotation.Description);
      }
      

      每次我尝试编译程序时都会抛出异常

        
          

      System.InvalidOperationException:应用程序默认值     凭证不可用。它们是可用的     在Google Compute Engine中运行。除此以外,     环境变量GOOGLE_APPLICATION_CREDENTIALS     必须定义指向定义凭据的文件。     见https://developers.google.com/accounts/docs/     application-default-credentials以获取更多信息。

        

      我需要帮助来设置默认凭据,我尝试了谷歌的许多链接 文件,但没有运气。 有没有人知道如何处理这个异常。

0 个答案:

没有答案
相关问题