C# Google.API.Auth.OAuth2.Responses.TokenResponseException:授权无效,机器人已禁用

C# Google.API.Auth.OAuth2.Responses.TokenResponseException:授权无效,机器人已禁用,c#,.net,google-cloud-storage,google-speech-api,visual-studio-mac,C#,.net,Google Cloud Storage,Google Speech Api,Visual Studio Mac,我正在使用Visual Studio for Mac进行一个使用Google语音API的.NET控制台C#项目 我收到一个错误,上面写着: Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin. Google.Apis.Auth.

我正在使用Visual Studio for Mac进行一个使用Google语音API的.NET控制台C#项目

我收到一个错误,上面写着:

Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin. Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"invalid_grant", Description:"Robot is disabled.", Uri:""
   at Google.Apis.Auth.OAuth2.Requests.TokenRequestExtenstions.ExecuteAsync(TokenRequest request, HttpClient httpClient, String tokenServerUrl, CancellationToken taskCancellationToken, IClock clock) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\Requests\TokenRequestExtenstions.cs:line 52
   at Google.Apis.Auth.OAuth2.ServiceAccountCredential.RequestAccessTokenAsync(CancellationToken taskCancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\ServiceAccountCredential.cs:line 212
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.RefreshTokenAsync() in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 129
   at Google.Apis.Auth.OAuth2.TokenRefreshManager.GetAccessTokenForRequestAsync(CancellationToken cancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\TokenRefreshManager.cs:line 114
   at Google.Apis.Auth.OAuth2.ServiceAccountCredential.GetAccessTokenForRequestAsync(String authUri, CancellationToken cancellationToken) in C:\Apiary\support1351\Src\Support\Google.Apis.Auth\OAuth2\ServiceAccountCredential.cs:line 235
   at Grpc.Auth.GoogleAuthInterceptors.<>c__DisplayClass2_0.<<FromCredential>b__0>d.MoveNext() in T:\src\github\grpc\src\csharp\Grpc.Auth\GoogleAuthInterceptors.cs:line 48
--- End of stack trace from previous location where exception was thrown ---
   at Grpc.Core.Internal.NativeMetadataCredentialsPlugin.GetMetadataAsync(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeMetadataCredentialsPlugin.cs:line 83")'

我该如何解决这个问题?我还需要为Google设置其他功能吗?

建议更新到新版本的Google.Cloud.PubSub.V1,这将引入更新版本的Grpc.Core。
使用Google.api.Auth的上一次更新。

结果表明,我使用了错误的json文件。愚蠢的错误。

嗨,丹尼尔,请不要提供敏感信息,如API密钥。我强烈建议您删除它并创建一个新的。@Christopher看起来好像有人已经修复了它。谢谢你提醒我。我完全忽略了这一点。我知道不应该这样做。如果服务帐户被禁用,您也会遇到此错误。可以使用
gcloud iam服务帐户启用来启用禁用的帐户myservice@myproject-123456.iam.gserviceaccount.com
class Program
{
    static void Main(string[] args)
    {
        var URI = "https://speech.googleapis.com/v1/speech:recognize?key=[API_KEY]";

        Console.WriteLine("Start!");

        AsyncRecognizeGcs(URI);

        Console.WriteLine("End.");

    }

    static object AsyncRecognizeGcs(string storageUri)
    {
        var speech = SpeechClient.Create();
        var longOperation = speech.LongRunningRecognize(new RecognitionConfig()
        {
            Encoding = RecognitionConfig.Types.AudioEncoding.Flac,
            SampleRateHertz = 44100,
            AudioChannelCount = 2,
            LanguageCode = "en",
        }, RecognitionAudio.FromStorageUri(storageUri)); // error here
        longOperation = longOperation.PollUntilCompleted();
        var response = longOperation.Result;
        foreach (var result in response.Results)
        {
            foreach (var alternative in result.Alternatives)
            {
                Console.WriteLine($"Transcript: { alternative.Transcript}");
            }
        }
        return 0;
    }

}