gpt4 book ai didi

C# .net MVC,设置 Google Application Credentials JSON 文件的路径

转载 作者:可可西里 更新时间:2023-11-01 09:00:05 32 4
gpt4 key购买 nike

我刚刚获得了这个 Google 示例项目,可以在我的 VS2015 上运行,

但是我发布到“IIS”并托管后,当我打开链接时,网页一直显示如图所示的消息

Error Picture

我将 key 添加到 web.config 中,但仍然不起作用,只是想知道以前是否有人这样做过,我真的需要帮助,谢谢!

编辑:这是我的代码

Web.Config

  <appSettings>
<!-- Set to your Google project id as shown on the Google Developers Console -->
<add key="GoogleCloudSamples:ProjectId" value="gdtest-1332" />
<add key="GOOGLE_APPLICATION_CREDENTIALS" value="D:\ProjectCloud\gdtest-12323.json" />
<!--
Set to either mysql or datastore.
If using mysql, update the connectionString far below, and then run Update-Database in the
Package Manager Console.
-->
<add key="GoogleCloudSamples:BookStore" value="datastore" />
<!-- Set to your Google Cloud Storage bucket -->
<add key="GoogleCloudSamples:BucketName" value="cloudstoragetestbillez" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

最佳答案

在运行时以编程方式设置环境变量:

string credential_path = @"C:\..\key.json";
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credential_path);

我不是 IIS 专家,但它似乎无法识别您桌面环境中设置的环境变量。

关于C# .net MVC,设置 Google Application Credentials JSON 文件的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37626200/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com