-1

我的问题很简单,我希望能够使用谷歌人才解决方案 API,创建一些模拟的工作和公司,并使用它们来执行虚拟搜索。我正在使用 PHP,这对我来说也很新,目前不能使用其他任何东西来实现,除非它与 PHP 一起使用。例如,我创建公司的代码在 PHP 中可以很好地硬编码,并返回成功消息,但如果我想使用 html/php 表单来执行此操作。我在提交表单时收到以下错误:

致命错误:未捕获的 DomainException:无法加载默认凭据。浏览到https://developers.google.com/accounts/docs/application-default-credentials以了解 /Users/shaun/Sites/gts/vendor/google/auth/src/ApplicationDefaultCredentials.php:168 中的更多信息

堆栈跟踪:

#0 /Users/shaun/Sites/gts/vendor/google/gax/src/CredentialsWrapper.php(197): Google\Auth\ApplicationDefaultCredentials::getCredentials(Array, Object(Google\Auth\HttpHandler\Guzzle6HttpHandler), NULL,无效的)

#1 /Users/shaun/Sites/gts/vendor/google/gax/src/CredentialsWrapper.php(114): Google\ApiCore\CredentialsWrapper::buildApplicationDefaultCredentials(Array, Object(Google\Auth\HttpHandler\Guzzle6HttpHandler))

#2 /Users/shaun/Sites/gts/vendor/google/gax/src/GapicClientTrait.php(339): Google\ApiCore\CredentialsWrapper::build(Array)

#3 /Users/shaun/Sites/gts/vendor/google/gax/src/GapicClientTrait.php(321): Google\Cloud\Talent\V4beta1\Gapic\CompanyServiceGapicClient->createCredentialsWrapper(NULL, Array)

#4 /Users/shaun/Sites/gts/vendor/google/cl 在 /Users/shaun/Sites/gts/vendor/google/gax/src/CredentialsWrapper.php 第 200 行

任何有关如何启用凭据的帮助将不胜感激。我已经尝试将凭据导出到终端上的相对 .json 并在 php 中的全局变量中进行编码。到目前为止没有运气,虽然也许我做错了。

我还授权了域“lvh.me”。

4

1 回答 1

1

问题已解决,没有像这样使用 putenv() 变量:

putenv("GOOGLE_APPLICATION_CREDENTIALS=" . $GOOGLE_APPLICATION_CREDENTIALS);

于 2019-12-13T09:13:43.630 回答