我正嘗試在WinForms(.NET)項目中使用Google Vision API。我已在Google Cloud Platform中註冊並啓用了Vision API。在授權過程中遵循Google Cloud標準步驟後,我創建並下載了JSON格式的服務密鑰。就它而言,GOOGLE_APPLICATION_CREDENTIALS也被設置爲指向密鑰文件(我之前提到的JSON文件)。就API而言,Google雲端平臺中的所有設置都很不錯。使用Google Vision API密鑰時遇到問題
我想知道爲什麼我收到異常
Grpc.Core.RpcException: 'Status(StatusCode=Unauthenticated,Detail="Getting metadata from plugin failed with error: Exception occured in metadata credentials plugin.")'
這裏就是拋出異常的方法的代碼:
var client = ImageAnnotatorClient.Create();
var image = Image.FromFile(filePath);
var response = client.DetectText(image); // <- here exception is thrown
附:我對這個話題做了一個重要的研究。我知道這似乎是認證有問題,但無法弄清楚究竟是什麼錯誤。
P.S.S如果您有任何參考資料或教程,請不要猶豫,向我提供。