无法在C#中找到toChannelCredentials()以进行Google API身份验证

问题描述 投票:0回答:1

在此页面上,https://cloud.google.com/docs/authentication/production,有一个指南,其中包含有关如何设置Google API身份验证的示例。但是,我的IDE似乎不理解或无法找到验证所需的“ToChannelCredentials()”方法。有没有特定的东西我还没有进口?这是我的代码

using System;
using System.IO;
using Grpc.Core;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Vision.V1;
namespace ClassLibrary1
{
    public class Class1
    {
        public static void Main(String[] args)
        {
            var credential = GoogleCredential.FromFile("myPath").CreateScoped(ImageAnnotatorClient.DefaultScopes);
            var channel = new Grpc.Core.Channel(ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.;
            var client = ImageAnnotatorClient.Create();
            var image = Image.FromFile("myImage");
            var response = client.DetectLabels(image);
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                {
                    Console.WriteLine(annotation.Description);
                }

            }
        }

    }
}
c# authentication google-authentication google-vision
1个回答
1
投票

加:

使用Grpc.Auth;

你需要引用Google.Apis.Core。

© www.soinside.com 2019 - 2024. All rights reserved.