在此页面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);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)