0

I have created a web api method to Speech to text using Google Speech library. It is working fine when I execute using the visual studio. After hosting the application on IIS, I am getting below error when the api method is called

Method:Status(StatusCode=Unauthenticated, Detail="Getting metadata from plugin failed with error: Exception occurred in metadata credentials plugin.")

Error at line with code:

var speechResponse = speech.Recognize(SpeechConfig,
        RecognitionAudio.FromFile(fileToProcess));* 

And on another system, I have configured the GOOGLE_APPLICATION_CREDENTIALS env avariable with service account json, but I am getting below error

The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • In your first system, are you specifying `GOOGLE_APPLICATION_CREDENTIALS` or not? On the second system, you really, really shouldn't be getting that error if you've got the environment variable set. Can you add logging for `Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS")` to check that it really is what you expect it to be? – Jon Skeet Jan 24 '18 at 16:29
  • Additionally, I'd expect to see some other information in the first exception, which would usually give details about what went wrong in the credentials plugin. It's probably simplest to address each system separately though, as they're behaving differently. – Jon Skeet Jan 24 '18 at 16:30
  • On both Systems, the GOOGLE_APPLICATION_CREDENTIALS env variable is pointed to Json file. Able to get value using Environment.GetEnvironmentVariable("GOOGLE_APPLICATION_CREDE‌​NTIALS"). – Harish Kumar Jan 25 '18 at 11:47
  • In that case I don't understand how you'd end up with that error - see https://github.com/google/google-api-dotnet-client/blob/master/Src/Support/Google.Apis.Auth/OAuth2/DefaultCredentialProvider.cs#L84. If the environment variable is set, it shouldn't be possible to fall down to the code that throws that exception. When you say you're able to get the value - do you mean in the same application code? You might want to simplify the diagnostics for this by calling `GoogleCredential.GetApplicationDefault()`. – Jon Skeet Jan 25 '18 at 11:49
  • I was able to resolve the second issue "The Application Default Credentials are not available. " by initializing the gcloud on server – Harish Kumar Jan 31 '18 at 08:46
  • I'm surprised that was necessary - if the environment variable is set and available, it should be fine. But it would still be good to make this question about one specific case, and maybe ask a second question if necessary. It's much easier to help with one thing at a time. – Jon Skeet Jan 31 '18 at 08:48

1 Answers1

0
  1. Do you also have compact framework sdk installed for visual studio? if try adding

    < NoStdLib > False< / NoStdLib >

in your *.csproj file. This would force VS to use the std mscorlib.dll instead of compact one.

  1. Check if the date and time on your system are correct (should be with 60 seconds of actual time)
Community
  • 1
  • 1