我正在尝试在我的Xamarin.Forms PCL-Project(可移植类库)中对Google Cloud Speech Api进行身份验证 . 我正在使用Android手机进行测试 . 我的解决方案的代码如下:

Assembly assembly = typeof(Program).GetTypeInfo().Assembly;
        Stream stream = assembly.GetManifestResourceStream("ConsoleApp1.speech_auth.json");

        string resultString = null;

        using (StreamReader reader = new StreamReader(stream))
        {
            resultString = reader.ReadToEnd();
        }

        GoogleCredential credential = GoogleCredential.FromJson(resultString);

        if (credential.IsCreateScopedRequired)
        {
            credential = credential.CreateScoped(new[] { "https://www.googleapis.com/auth/cloud-platform" });
        }

        var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host,
            credential.ToChannelCredentials());

        var speech = SpeechClient.Create(channel);
        var response = speech.Recognize(new RecognitionConfig()
                                            {
                                                Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
                                                SampleRateHertz = 16000,
                                                LanguageCode = "de-CH",
                                            }, RecognitionAudio.FromFile("test.flac"));

在通常的.NET ConsoleApplication-Project中,它的工作方式就像魅力一样 . 但是,如果我在我的PCL-Project中尝试完全相同的代码,我会在以下行中收到错误:

var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host,
            credential.ToChannelCredentials());

其中说:

未处理的异常:System.NotImplementedException:未实现方法或操作

我在我的PCL和Android-Project上安装了所有Nuget GRPC和Google Speech API-Packages .

所以我的问题是:

Is there a better / easier way to authenticate to the Google Cloud Speech API, using Xamarin.Forms? If not, whats the problem with my code?

Edit: It seems that Xamarin does not support gRPC. I've managed to call the speech API sending a request using a simple httpClient.