c# - 使用 google Cloud Vision API 的运输应用程序
问题描述
Google 使用存储在本地机器中的 JSON 文件验证对其 Cloud API 的请求。我需要设置 JSON 文件的路径以使用该库
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", @"C:\Users\admin\Downloads\vision.json");
因此,如果我要发送应用程序,是否也需要发送 JSON?不会带来安全风险吗?
更新 1:
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", @"vision.json");
client = ImageAnnotatorClient.Create();
更新 2:
我正在使用下面的代码从文件创建凭据。我打算加密这个 JSON 文件;将其托管在服务器中。下载它,在客户端对其进行解密并从中创建凭据。
我的问题是没有将 JSON 本地存储在磁盘中,我可以将它存储在内存中并从中创建凭证吗?
var credential = GoogleCredential.FromFile("vision.json").CreateScoped(ImageAnnotatorClient.DefaultScopes);
var channel = new Grpc.Core.Channel(
ImageAnnotatorClient.DefaultEndpoint.ToString(),
credential.ToChannelCredentials());
client = ImageAnnotatorClient.Create(channel);
解决方案
推荐阅读
- mysql - mysql使用变量来决定是否执行插入
- class - 为什么我收到错误消息:“Credis_Client::scan() 的参数 1 应为参考”?
- flutter-listview - Listview Builder On Scroll child == null 或 hasSize == null 等
- javascript - 从 Node child_process 执行 Argo Tunnel 时出现错误 1016
- html - 在IOS上悬停后如何返回原始位置
- perl - XML::LibXML::Pattern 安装失败
- forms - 如何将处理时间保持在 OnSleep() 内?
- ansible - 我如何在ansible的变量文件中改变dict键
- android - 片段竞赛片段{3fa10a4} 未附加到上下文
- python-3.x - 如何根据zmq订阅的消息更新pymodbus tcp server的值?